cancel gatherCompletions if cursor position changes

This commit is contained in:
nightwing 2015-01-12 01:13:27 +04:00
commit 100022564c

View file

@ -43,6 +43,7 @@ var Autocomplete = function() {
this.autoInsert = true;
this.autoSelect = true;
this.exactMatch = false;
this.gatherCompletionsId = 0;
this.keyboardHandler = new HashHandler();
this.keyboardHandler.bindKeys(this.commands);
@ -59,7 +60,6 @@ var Autocomplete = function() {
};
(function() {
this.gatherCompletionsId = 0;
this.$init = function() {
this.popup = new AcePopup(document.body || document.documentElement);
@ -84,6 +84,8 @@ var Autocomplete = function() {
this.popup.setData(this.completions.filtered);
editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
var renderer = editor.renderer;
this.popup.setRow(this.autoSelect ? 0 : -1);
if (!keepPopupPosition) {
@ -115,10 +117,9 @@ var Autocomplete = function() {
this.changeTimer.cancel();
this.hideDocTooltip();
if (this.popup && this.popup.isOpen) {
this.gatherCompletionsId += 1;
this.gatherCompletionsId += 1;
if (this.popup && this.popup.isOpen)
this.popup.hide();
}
if (this.base)
this.base.detach();
@ -261,7 +262,6 @@ var Autocomplete = function() {
editor.completer = this;
}
editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
editor.on("changeSelection", this.changeListener);
editor.on("blur", this.blurListener);
editor.on("mousedown", this.mousedownListener);