浏览代码

[notebook] Don't auto-trigger hdfs autocomplete for URIs with schema references

Before this change it also triggered the autocomplete after ://
Johan Ahlen 10 年之前
父节点
当前提交
4934f17

+ 1 - 4
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -1968,7 +1968,7 @@
 
 
       editor.commands.on("afterExec", function (e) {
       editor.commands.on("afterExec", function (e) {
         if (e.command.name === "insertstring") {
         if (e.command.name === "insertstring") {
-          var triggerAutocomplete = /\.$/.test(e.args);
+          var triggerAutocomplete = ((editor.session.getMode().$id == "ace/mode/hive" || editor.session.getMode().$id == "ace/mode/impala") && e.args == ".") || /["']\/[^\/]*/.test(editor.getTextBeforeCursor());
           if(e.args.toLowerCase().indexOf("? from ") == 0) {
           if(e.args.toLowerCase().indexOf("? from ") == 0) {
             editor.moveCursorTo(editor.getCursorPosition().row, editor.getCursorPosition().column - e.args.length + 1);
             editor.moveCursorTo(editor.getCursorPosition().row, editor.getCursorPosition().column - e.args.length + 1);
             editor.removeTextBeforeCursor(1);
             editor.removeTextBeforeCursor(1);
@@ -1982,9 +1982,6 @@
           }
           }
         }
         }
         editor.session.getMode().$id = snippet.getAceMode(); // forces the id again because of Ace command internals
         editor.session.getMode().$id = snippet.getAceMode(); // forces the id again because of Ace command internals
-        if (e.args === '/' || ((editor.session.getMode().$id == "ace/mode/hive" || editor.session.getMode().$id == "ace/mode/impala") && e.args == ".")) {
-          editor.execCommand("startAutocomplete");
-        }
         // if it's pig and before it's LOAD ' we disable the autocomplete and show a filechooser btn
         // if it's pig and before it's LOAD ' we disable the autocomplete and show a filechooser btn
         if (editor.session.getMode().$id = "ace/mode/pig" && e.args) {
         if (editor.session.getMode().$id = "ace/mode/pig" && e.args) {
           var textBefore = editor.getTextBeforeCursor();
           var textBefore = editor.getTextBeforeCursor();

+ 9 - 0
desktop/core/src/desktop/static/desktop/spec/hdfsAutocompleterSpec.js

@@ -93,6 +93,15 @@ define([
       });
       });
     });
     });
 
 
+    it("should return empty suggestions for URIs with schemes ", function() {
+      assertAutoComplete({
+        serverResponses: {},
+        beforeCursor: "://blabla",
+        afterCursor: "",
+        expectedSuggestions: []
+      });
+    });
+
     it("should return suggestions for root with '", function() {
     it("should return suggestions for root with '", function() {
       assertAutoComplete({
       assertAutoComplete({
         serverResponses: {
         serverResponses: {