diff options
author | Wu Cheng-Han | 2015-07-04 11:31:01 +0800 |
---|---|---|
committer | Wu Cheng-Han | 2015-07-04 11:31:01 +0800 |
commit | 01685c255fda6e13f1cd2980130d2e388d52125c (patch) | |
tree | c329610e7011c0d77c55ef54f371181aeb362d13 /public/vendor/codemirror/addon/hint/show-hint.js | |
parent | 1d843c8ac257d512a96cf054ab24e6a3c2f34e26 (diff) |
Updated codemirror to 5.4.0
Diffstat (limited to 'public/vendor/codemirror/addon/hint/show-hint.js')
-rwxr-xr-x | public/vendor/codemirror/addon/hint/show-hint.js | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/public/vendor/codemirror/addon/hint/show-hint.js b/public/vendor/codemirror/addon/hint/show-hint.js index 539181fd..d228fc88 100755 --- a/public/vendor/codemirror/addon/hint/show-hint.js +++ b/public/vendor/codemirror/addon/hint/show-hint.js @@ -33,7 +33,7 @@ if (!completion.options.hint) return; CodeMirror.signal(this, "startCompletion", this); - completion.update(); + completion.update(true); }); function Completion(cm, options) { @@ -61,6 +61,7 @@ this.tick = null; this.cm.off("cursorActivity", this.activityFunc); + if (this.widget && this.data) CodeMirror.signal(this.data, "close"); if (this.widget) this.widget.close(); CodeMirror.signal(this.cm, "endCompletion", this.cm); }, @@ -78,15 +79,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,35 +97,34 @@ } }, - 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); - else this.widget = new Widget(this, data); + if (picked && data.list.length == 1) { + this.pick(data, 0); + } else { + this.widget = new Widget(this, data); + CodeMirror.signal(data, "shown"); + } } }, - 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 = {}; |