First round of code review addressed

pull/538/head
Maxim Shishmarev 6 years ago
parent 4e39f1e0eb
commit 0980eafe74

@ -2215,15 +2215,7 @@
const pos = $input.selectionStart; const pos = $input.selectionStart;
const part = isDelete ? text.substr(pos) : text.substr(0, pos); const part = isDelete ? text.substr(pos) : text.substr(0, pos);
let curMention = null; const curMention = _.keys(mentions).find(key => predicate(part, key));
_.forEach(mentions, (val, key) => {
let shouldContinue = true;
if (predicate(part, key)) {
curMention = key;
shouldContinue = false;
}
return shouldContinue;
});
if (!curMention) { if (!curMention) {
return; return;
@ -2239,9 +2231,14 @@
: text.substr(pos); : text.substr(pos);
const resText = beforeMention + afterMention; const resText = beforeMention + afterMention;
// NOTE: this doesn't work well with undo/redo, perhaps
// we should fix it one day
this.$messageField.val(resText); this.$messageField.val(resText);
$input.selectionStart = pos;
$input.selectionEnd = pos; const nextPos = isDelete ? pos : pos - curMention.length;
$input.selectionStart = nextPos;
$input.selectionEnd = nextPos;
this.memberView.deleteMention(curMention); this.memberView.deleteMention(curMention);
}, },
@ -2269,15 +2266,7 @@
? window.Lodash.endsWith ? window.Lodash.endsWith
: window.Lodash.startsWith; : window.Lodash.startsWith;
let curMention = null; const curMention = _.keys(mentions).find(key => predicate(part, key));
_.forEach(mentions, (val, key) => {
let shouldContinue = true;
if (predicate(part, key)) {
curMention = key;
shouldContinue = false;
}
return shouldContinue;
});
const offset = curMention ? curMention.length : 1; const offset = curMention ? curMention.length : 1;

Loading…
Cancel
Save