Commit 585a1775 authored by ThorbenQuast's avatar ThorbenQuast
Browse files

[editor] schedule the autocompletion (i.e. add 500ms delay and require >= 2 letters)

parent a2ae7e20
......@@ -310,7 +310,7 @@ define(["jquery", "emitter", "./action", "require", "ace/ace", "ace/ext-language
enableLiveAutocompletion: enable,
enableSnippets: enable,
liveAutocompletionDelay: 500,
liveAutocompletionThreshold: 3
liveAutocompletionThreshold: 2
});
},
......
......@@ -1866,7 +1866,7 @@ function getCompletionPrefix(editor) {
}
});
return prefix || util.retrievePrecedingIdentifier(line, pos.column);
}
};
var doLiveAutocomplete = function(e) {
var editor = e.editor;
......@@ -1877,7 +1877,8 @@ var doLiveAutocomplete = function(e) {
}
else if (e.command.name === "insertstring") {
var prefix = getCompletionPrefix(editor);
if (prefix && !hasCompleter) {
//if (prefix && !hasCompleter) {
if (prefix && prefix.length >= editor.$liveAutocompletionThreshold && !hasCompleter) { //CHECK ME
if (!editor.completer) {
editor.completer = new Autocomplete();
}
......@@ -1887,6 +1888,15 @@ var doLiveAutocomplete = function(e) {
}
};
//check me from here
var lastExec_e;
var liveAutocompleteTimer = lang.delayedCall(function () { doLiveAutocomplete(lastExec_e); }, 0);
var scheduleAutocomplete = function(e) {
lastExec_e = e;
liveAutocompleteTimer.delay(e.editor.$liveAutocompletionDelay);
};
//until here
var Editor = require("../editor").Editor;
require("../config").defineOptions(Editor.prototype, "editor", {
enableBasicAutocompletion: {
......@@ -1906,13 +1916,24 @@ require("../config").defineOptions(Editor.prototype, "editor", {
if (val) {
if (!this.completers)
this.completers = Array.isArray(val)? val: completers;
this.commands.on('afterExec', doLiveAutocomplete);
//this.commands.on('afterExec', doLiveAutocomplete);
this.commands.on('afterExec', scheduleAutocomplete); //CHECK ME
} else {
this.commands.removeListener('afterExec', doLiveAutocomplete);
//this.commands.removeListener('afterExec', doLiveAutocomplete);
this.commands.removeListener('afterExec', scheduleAutocomplete); //CHECK ME
}
},
value: false
},
//Check me from here
// (default values)
liveAutocompletionDelay: {
value: 100
},
liveAutocompletionThreshold: {
value: 0
},
//to here!
enableSnippets: {
set: function(val) {
if (val) {
......
......@@ -40,7 +40,8 @@ var supportedModes = {
ADA: ["ada|adb"],
Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],
AsciiDoc: ["asciidoc|adoc"],
Assembly_x86:["asm"],
//Assembly_x86:["asm"],
Assembly_x86:["asm|s"], //CHECK ME
AutoHotKey: ["ahk"],
BatchFile: ["bat|cmd"],
C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp"],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment