Merge pull request #2027 from ajaxorg/autocomplete

Tweak autocomplete
This commit is contained in:
Fabian Jakobs 2014-07-07 15:08:28 +02:00
commit 779912d517
6 changed files with 19 additions and 19 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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"

View file

@ -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();
}
}
};

View file

@ -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);

View file

@ -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()
};