Эх сурвалжийг харах

[core] Trigger ace autocomplete after completions that ends with "."

Johan Ahlen 10 жил өмнө
parent
commit
98b496e

+ 13 - 6
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -1995,12 +1995,19 @@ ko.bindingHandlers.aceEditor = {
     });
 
     editor.commands.on("afterExec", function (e) {
-      if (e.command.name === "insertstring" && e.args.toLowerCase().indexOf("? from ") == 0) {
-        editor.moveCursorTo(editor.getCursorPosition().row, editor.getCursorPosition().column - e.args.length + 1);
-        editor.removeTextBeforeCursor(1);
-        window.setTimeout(function () {
-          editor.execCommand("startAutocomplete");
-        }, 100);
+      if (e.command.name === "insertstring") {
+        var triggerAutocomplete = /\.$/.test(e.args);
+        if(e.args.toLowerCase().indexOf("? from ") == 0) {
+          editor.moveCursorTo(editor.getCursorPosition().row, editor.getCursorPosition().column - e.args.length + 1);
+          editor.removeTextBeforeCursor(1);
+          triggerAutocomplete = true;
+        }
+
+        if (triggerAutocomplete) {
+          window.setTimeout(function () {
+            editor.execCommand("startAutocomplete");
+          }, 100);
+        }
       }
       editor.session.getMode().$id = valueAccessor().mode(); // forces the id again because of Ace command internals
       if ((editor.session.getMode().$id == "ace/mode/hive" || editor.session.getMode().$id == "ace/mode/impala") && e.args == ".") {