Skip to content

Commit 37e9e29

Browse files
author
neustadt
committed
optimized and streamlined codemirror autocompletion
1 parent 222363e commit 37e9e29

File tree

1 file changed

+14
-11
lines changed
  • Resources/views/backend/wbm_query_manager/view/main

1 file changed

+14
-11
lines changed

Resources/views/backend/wbm_query_manager/view/main/detail.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,20 @@ Ext.define('Shopware.apps.WbmQueryManager.view.main.Detail', {
6464
tables: Ext.decode('{$hintOptions}')
6565
});
6666
var hintDelay = null;
67-
editor.on("keyup", function (cm, event) {
68-
if ([13,32,37,38,39,40].indexOf(event.keyCode) === -1) {
69-
clearTimeout(hintDelay);
70-
if(cm.state.completionActive){
71-
cm.state.completionActive.close();
72-
}
73-
hintDelay = setTimeout(function() {
74-
CodeMirror.commands.autocomplete(cm, null, { completeSingle: false });
75-
}, 1500);
76-
} else {
77-
clearTimeout(hintDelay);
67+
editor.on("keyup", function (instance, event) {
68+
if (instance.state.completionActive) {
69+
return;
70+
}
71+
var cur = instance.getCursor(),
72+
token = instance.getTokenAt(cur),
73+
string = '';
74+
if (token.string.match(/^[.`\w@]\w*$/)) {
75+
string = token.string;
76+
}
77+
if (string.length > 0) {
78+
CodeMirror.commands.autocomplete(instance, null, {
79+
completeSingle: false
80+
});
7881
}
7982
});
8083
//{/if}

0 commit comments

Comments
 (0)