Skip to content

Commit d49ef29

Browse files
committed
Adjust hint.fromList to consistenly use the cursor as end pos
Issue codemirror#5312
1 parent e732d0e commit d49ef29

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

addon/hint/show-hint.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -397,13 +397,13 @@
397397
});
398398

399399
CodeMirror.registerHelper("hint", "fromList", function(cm, options) {
400-
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
401-
var to = CodeMirror.Pos(cur.line, token.end);
402-
if (token.string && /\w/.test(token.string[token.string.length - 1])) {
403-
var length = token.string.length - (token.end - cur.ch);
404-
var term = token.string.substr(0, length), from = CodeMirror.Pos(cur.line, token.start);
400+
var cur = cm.getCursor(), token = cm.getTokenAt(cur)
401+
var term, from = CodeMirror.Pos(cur.line, token.start), to = cur
402+
if (token.start < cur.ch && /\w/.test(token.string.charAt(cur.ch - token.start - 1))) {
403+
term = token.string.substr(0, cur.ch - token.start)
405404
} else {
406-
var term = "", from = to;
405+
term = ""
406+
from = cur
407407
}
408408
var found = [];
409409
for (var i = 0; i < options.words.length; i++) {

0 commit comments

Comments
 (0)