Skip to content
Snippets Groups Projects
Commit bb61349f authored by Marijn Haverbeke's avatar Marijn Haverbeke
Browse files

[show-hint addon] Fix completeSingle options

Issue #3189
parent dafd32fd
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,7 @@
if (!completion.options.hint) return;
CodeMirror.signal(this, "startCompletion", this);
completion.update();
completion.update(true);
});
function Completion(cm, options) {
......@@ -78,15 +78,6 @@
this.close();
},
showHints: function(data) {
if (!data || !data.list.length || !this.active()) return this.close();
if (this.options.completeSingle && data.list.length == 1)
this.pick(data, 0);
else
this.showWidget(data);
},
cursorActivity: function() {
if (this.debounce) {
cancelAnimationFrame(this.debounce);
......@@ -105,22 +96,23 @@
}
},
update: function() {
update: function(first) {
if (this.tick == null) return;
if (this.data) CodeMirror.signal(this.data, "update");
if (!this.options.hint.async) {
this.finishUpdate(this.options.hint(this.cm, this.options), myTick);
this.finishUpdate(this.options.hint(this.cm, this.options), first);
} else {
var myTick = ++this.tick, self = this;
this.options.hint(this.cm, function(data) {
if (self.tick == myTick) self.finishUpdate(data);
if (self.tick == myTick) self.finishUpdate(data, first);
}, this.options);
}
},
finishUpdate: function(data) {
finishUpdate: function(data, first) {
this.data = data;
var picked = this.widget && this.widget.picked;
var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle);
if (this.widget) this.widget.close();
if (data && data.list.length) {
if (picked && data.list.length == 1) this.pick(data, 0);
......@@ -128,12 +120,6 @@
}
},
showWidget: function(data) {
this.data = data;
this.widget = new Widget(this, data);
CodeMirror.signal(data, "shown");
},
buildOptions: function(options) {
var editor = this.cm.options.hintOptions;
var out = {};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment