diff --git a/lib/ace/autocomplete.js b/lib/ace/autocomplete.js index adf9bd73..13d140d9 100644 --- a/lib/ace/autocomplete.js +++ b/lib/ace/autocomplete.js @@ -101,12 +101,12 @@ var Autocomplete = function() { this.changeTimer.cancel(); if (this.popup && this.popup.isOpen) { - this.gatherCompletionsId = this.gatherCompletionsId + 1; - } - - if (this.popup) + this.gatherCompletionsId += 1; this.popup.hide(); - + } + + if (this.base) + this.base.detach(); this.activated = false; this.completions = this.base = null; }; @@ -205,8 +205,7 @@ var Autocomplete = function() { var line = session.getLine(pos.row); var prefix = util.retrievePrecedingIdentifier(line, pos.column); - this.base = editor.getCursorPosition(); - this.base.column -= prefix.length; + this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length); var matches = []; var total = editor.completers.length; diff --git a/lib/ace/autocomplete/popup.js b/lib/ace/autocomplete/popup.js index a0ab7604..a34ebf09 100644 --- a/lib/ace/autocomplete/popup.js +++ b/lib/ace/autocomplete/popup.js @@ -67,6 +67,7 @@ var AcePopup = function(parentNode) { popup.renderer.setStyle("ace_autocomplete"); popup.setOption("displayIndentGuides", false); + popup.setOption("dragDelay", 150); var noop = function(){}; @@ -178,7 +179,7 @@ var AcePopup = function(parentNode) { if (typeof data == "string") data = {value: data}; if (!data.caption) - data.caption = data.value; + data.caption = data.value || data.name; var last = -1; var flag, c; diff --git a/lib/ace/autocomplete/text_completer.js b/lib/ace/autocomplete/text_completer.js index 6eebfc61..17a4bdad 100644 --- a/lib/ace/autocomplete/text_completer.js +++ b/lib/ace/autocomplete/text_completer.js @@ -68,7 +68,7 @@ define(function(require, exports, module) { var wordList = Object.keys(wordScore); callback(null, wordList.map(function(word) { return { - name: word, + caption: word, value: word, score: wordScore[word], meta: "local" diff --git a/lib/ace/ext/language_tools.js b/lib/ace/ext/language_tools.js index dc56e6e0..d8b2a1dd 100644 --- a/lib/ace/ext/language_tools.js +++ b/lib/ace/ext/language_tools.js @@ -161,10 +161,6 @@ var doLiveAutocomplete = function(e) { editor.completer.autoSelect = false; editor.completer.autoInsert = false; editor.completer.showPopup(editor); - } else if (!prefix && hasCompleter) { - // When the prefix is empty - // close the autocomplete dialog - editor.completer.detach(); } } }; diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js index fbf37786..ed213d70 100644 --- a/lib/ace/keyboard/textinput.js +++ b/lib/ace/keyboard/textinput.js @@ -428,13 +428,17 @@ var TextInput = function(parentNode, host) { this.onContextMenu = function(e) { afterContextMenu = true; - if (!tempStyle) - tempStyle = text.style.cssText; - - text.style.cssText = "z-index:100000;" + (useragent.isIE ? "opacity:0.1;" : ""); - resetSelection(host.selection.isEmpty()); host._emit("nativecontextmenu", {target: host, domEvent: e}); + this.moveToMouse(e, true); + }; + + this.moveToMouse = function(e, bringToFront) { + if (!tempStyle) + tempStyle = text.style.cssText; + text.style.cssText = (bringToFront ? "z-index:100000;" : "") + + (useragent.isIE ? "opacity:0.1;" : ""); + var rect = host.container.getBoundingClientRect(); var style = dom.computedStyle(host.container); var top = rect.top + (parseInt(style.borderTopWidth) || 0); diff --git a/lib/ace/mouse/mouse_handler.js b/lib/ace/mouse/mouse_handler.js index ce88eb81..9cf26721 100644 --- a/lib/ace/mouse/mouse_handler.js +++ b/lib/ace/mouse/mouse_handler.js @@ -49,7 +49,7 @@ var MouseHandler = function(editor) { var focusEditor = function(e) { if (!editor.isFocused() && editor.textInput) - editor.textInput.onContextMenu(e); + editor.textInput.moveToMouse(e); editor.focus() };