mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Tweak autocomplete/caret_position logic to not exclude the index 0 case
This commit is contained in:
parent
7f08765ba7
commit
3a0227f868
2 changed files with 5 additions and 5 deletions
|
@ -126,7 +126,7 @@
|
|||
});
|
||||
};
|
||||
updateAutoComplete = function(r) {
|
||||
if (!completeStart) return;
|
||||
if (completeStart === null) return;
|
||||
|
||||
autocompleteOptions = r;
|
||||
if (!r || r.length === 0) {
|
||||
|
@ -197,7 +197,7 @@
|
|||
if (e.which === 16) {
|
||||
return;
|
||||
}
|
||||
if ((!completeStart) && e.which === 8 && options.key) {
|
||||
if ((completeStart === null) && e.which === 8 && options.key) {
|
||||
c = Discourse.Utilities.caretPosition(me[0]);
|
||||
next = me[0].value[c];
|
||||
nextIsGood = next === void 0 || /\s/.test(next);
|
||||
|
@ -222,13 +222,13 @@
|
|||
}
|
||||
}
|
||||
if (e.which === 27) {
|
||||
if (completeStart) {
|
||||
if (completeStart !== null) {
|
||||
closeAutocomplete();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (completeStart) {
|
||||
if (completeStart !== null) {
|
||||
caretPosition = Discourse.Utilities.caretPosition(me[0]);
|
||||
/* If we've backspaced past the beginning, cancel unless no key
|
||||
*/
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
});
|
||||
before = void 0;
|
||||
after = void 0;
|
||||
pos = options && options.pos ? options.pos : getCaret(textarea[0]);
|
||||
pos = options && (options.pos || options.pos === 0) ? options.pos : getCaret(textarea[0]);
|
||||
val = textarea.val().replace("\r", "");
|
||||
if (options && options.key) {
|
||||
val = val.substring(0, pos) + options.key + val.substring(pos);
|
||||
|
|
Loading…
Reference in a new issue