Skip to content

Commit f95803c

Browse files
committed
[show-hint addon] Don't close completion when text is moved
Closes codemirror#3849
1 parent 9a88838 commit f95803c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

addon/hint/show-hint.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,13 @@
121121

122122
finishUpdate: function(data, first) {
123123
if (this.data) CodeMirror.signal(this.data, "update");
124-
if (data && this.data && CodeMirror.cmpPos(data.from, this.data.from)) data = null;
125-
this.data = data;
126124

127125
var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle);
128126
if (this.widget) this.widget.close();
127+
128+
if (data && this.data && isNewCompletion(this.data, data)) return;
129+
this.data = data;
130+
129131
if (data && data.list.length) {
130132
if (picked && data.list.length == 1) {
131133
this.pick(data, 0);
@@ -137,6 +139,11 @@
137139
}
138140
};
139141

142+
function isNewCompletion(old, nw) {
143+
var moved = CodeMirror.cmpPos(nw.from, old.from)
144+
return moved > 0 && old.to.ch - old.from.ch != nw.to.ch - nw.from.ch
145+
}
146+
140147
function parseOptions(cm, pos, options) {
141148
var editor = cm.options.hintOptions;
142149
var out = {};

0 commit comments

Comments
 (0)