Merge pull request #3698 from tgxworld/autocomplete
FIX: Autocomplete and Emojis when bounded by non-word characters.
This commit is contained in:
commit
4d0460f760
|
@ -277,7 +277,7 @@ export default function(options) {
|
||||||
if (options.key && e.which === options.key.charCodeAt(0)) {
|
if (options.key && e.which === options.key.charCodeAt(0)) {
|
||||||
caretPosition = Discourse.Utilities.caretPosition(me[0]);
|
caretPosition = Discourse.Utilities.caretPosition(me[0]);
|
||||||
var prevChar = me.val().charAt(caretPosition - 1);
|
var prevChar = me.val().charAt(caretPosition - 1);
|
||||||
if (!prevChar || /\s/.test(prevChar)) {
|
if (!prevChar || /\W/.test(prevChar)) {
|
||||||
completeStart = completeEnd = caretPosition;
|
completeStart = completeEnd = caretPosition;
|
||||||
updateAutoComplete(options.dataSource(""));
|
updateAutoComplete(options.dataSource(""));
|
||||||
}
|
}
|
||||||
|
@ -331,7 +331,7 @@ export default function(options) {
|
||||||
stopFound = prev === options.key;
|
stopFound = prev === options.key;
|
||||||
if (stopFound) {
|
if (stopFound) {
|
||||||
prev = me[0].value[c - 1];
|
prev = me[0].value[c - 1];
|
||||||
if (!prev || /\s/.test(prev)) {
|
if (!prev || /\W/.test(prev)) {
|
||||||
completeStart = c;
|
completeStart = c;
|
||||||
caretPosition = completeEnd = initial;
|
caretPosition = completeEnd = initial;
|
||||||
term = me[0].value.substring(c + 1, initial);
|
term = me[0].value.substring(c + 1, initial);
|
||||||
|
|
|
@ -113,7 +113,7 @@ function checkPrev(prev) {
|
||||||
var lastToken = prev[prev.length-1];
|
var lastToken = prev[prev.length-1];
|
||||||
if (lastToken && lastToken.charAt) {
|
if (lastToken && lastToken.charAt) {
|
||||||
var lastChar = lastToken.charAt(lastToken.length-1);
|
var lastChar = lastToken.charAt(lastToken.length-1);
|
||||||
if (!/\s/.test(lastChar)) return false;
|
if (!/\W/.test(lastChar)) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue