zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prabhjyotsi...@apache.org
Subject zeppelin git commit: [ZEPPELIN-3001] Disable ace editor code completion when backend interpreter support completion
Date Mon, 02 Apr 2018 09:00:55 GMT
Repository: zeppelin
Updated Branches:
  refs/heads/branch-0.8 bbfae7c72 -> a7bf3ac4a


[ZEPPELIN-3001] Disable ace editor code completion when backend interpreter support completion

This is what I see in zeppelin and jupyter. The difference is due to zeppelin also add code
completion of ace editor. I think code completion of ace editor should only be enabled when
the backend interpreter doesn't support completion.

[Bug Fix]

* [ZEPPELIN-3001](https://issues.apache.org/jira/browse/ZEPPELIN-3001)

* Does the licenses files need update? N/A
* Is there breaking changes for older versions? N/A
* Does this needs documentation? N/A

Author: Prabhjyot Singh <prabhjyotsingh@gmail.com>

Closes #2885 from prabhjyotsingh/ZEPPELIN-3001 and squashes the following commits:

fcd551fe1 [Prabhjyot Singh] meta can be either empty string or undefined
e6ad8d1c7 [Prabhjyot Singh] Merge remote-tracking branch 'origin/master' into ZEPPELIN-3001
508cd239c [Prabhjyot Singh] fix websocketMsgSrv.completion paragraph id issue
9380c32fa [Prabhjyot Singh] upgrade ace-builds to 1.3.2
701f93f85 [Prabhjyot Singh] make default suggestion if there is no suggestion from back-end.
97f594dc8 [Prabhjyot Singh] completionSupport false for SparkRInterpreter
d2f70ae7d [Prabhjyot Singh] get completionSupport from interpreter (backend)
adaabcbf9 [Prabhjyot Singh] ZEPPELIN-3001: Disable ace editor code completion when back-end
interpreter support completion

Change-Id: I03e39422bafebf9c96b01b88f542a16dd6959f23
(cherry picked from commit fe07e5a4962f9457fc2aca473511a50a553499b0)
Signed-off-by: Prabhjyot Singh <prabhjyotsingh@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/a7bf3ac4
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/a7bf3ac4
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/a7bf3ac4

Branch: refs/heads/branch-0.8
Commit: a7bf3ac4a61c85729cd70d3fa0b6de8963226f98
Parents: bbfae7c
Author: Prabhjyot Singh <prabhjyotsingh@gmail.com>
Authored: Fri Mar 30 10:26:02 2018 +0530
Committer: Prabhjyot Singh <prabhjyotsingh@gmail.com>
Committed: Mon Apr 2 14:30:41 2018 +0530

----------------------------------------------------------------------
 .../src/main/resources/interpreter-setting.json |  3 +-
 .../src/main/resources/interpreter-setting.json |  3 +-
 .../src/main/resources/interpreter-setting.json |  3 +-
 .../src/main/resources/interpreter-setting.json |  3 +-
 .../src/main/resources/interpreter-setting.json |  3 +-
 .../src/main/resources/interpreter-setting.json |  4 +
 .../src/main/resources/interpreter-setting.json |  3 +-
 .../src/main/resources/interpreter-setting.json | 10 ++-
 .../src/main/resources/interpreter-setting.json |  3 +-
 .../src/main/resources/interpreter-setting.json |  3 +-
 .../src/main/resources/interpreter-setting.json |  4 +
 .../src/main/resources/interpreter-setting.json | 15 ++--
 .../src/main/resources/interpreter-setting.json |  3 +-
 .../src/main/resources/interpreter-setting.json | 15 ++--
 sap/src/main/resources/interpreter-setting.json |  3 +-
 .../src/main/resources/interpreter-setting.json |  3 +-
 .../src/main/resources/interpreter-setting.json | 18 +++--
 .../apache/zeppelin/socket/NotebookServer.java  |  8 +-
 zeppelin-web/bower.json                         |  6 +-
 .../notebook/paragraph/paragraph.controller.js  | 82 +++++++++++++++++++-
 20 files changed, 162 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a7bf3ac4/alluxio/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/alluxio/src/main/resources/interpreter-setting.json b/alluxio/src/main/resources/interpreter-setting.json
index b9ab898..7a8cd62 100644
--- a/alluxio/src/main/resources/interpreter-setting.json
+++ b/alluxio/src/main/resources/interpreter-setting.json
@@ -20,7 +20,8 @@
       }
     },
     "editor": {
-      "editOnDblClick": false
+      "editOnDblClick": false,
+      "completionSupport": true
     }
   }
 ]

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a7bf3ac4/angular/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/angular/src/main/resources/interpreter-setting.json b/angular/src/main/resources/interpreter-setting.json
index 4ff5978..723348d 100644
--- a/angular/src/main/resources/interpreter-setting.json
+++ b/angular/src/main/resources/interpreter-setting.json
@@ -6,7 +6,8 @@
     "properties": {
     },
     "editor": {
-      "editOnDblClick": true
+      "editOnDblClick": true,
+      "completionSupport": false
     }
   }
 ]

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a7bf3ac4/bigquery/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/bigquery/src/main/resources/interpreter-setting.json b/bigquery/src/main/resources/interpreter-setting.json
index 3e1f27a..8e92ee4 100644
--- a/bigquery/src/main/resources/interpreter-setting.json
+++ b/bigquery/src/main/resources/interpreter-setting.json
@@ -34,7 +34,8 @@
     },
     "editor": {
       "language": "sql",
-      "editOnDblClick": false
+      "editOnDblClick": false,
+      "completionSupport": false
     }
   }
 ]

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a7bf3ac4/elasticsearch/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/elasticsearch/src/main/resources/interpreter-setting.json b/elasticsearch/src/main/resources/interpreter-setting.json
index 6fac719..3e132f2 100644
--- a/elasticsearch/src/main/resources/interpreter-setting.json
+++ b/elasticsearch/src/main/resources/interpreter-setting.json
@@ -55,7 +55,8 @@
       }
     },
     "editor": {
-      "editOnDblClick": false
+      "editOnDblClick": false,
+      "completionSupport": true
     }
   }
 ]

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a7bf3ac4/file/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/file/src/main/resources/interpreter-setting.json b/file/src/main/resources/interpreter-setting.json
index ebe5cf6..83fcb3d 100644
--- a/file/src/main/resources/interpreter-setting.json
+++ b/file/src/main/resources/interpreter-setting.json
@@ -27,7 +27,8 @@
       }
     },
     "editor": {
-      "editOnDblClick": false
+      "editOnDblClick": false,
+      "completionSupport": true
     }
   }
 ]

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a7bf3ac4/groovy/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/groovy/src/main/resources/interpreter-setting.json b/groovy/src/main/resources/interpreter-setting.json
index 45aab84..4afec2a 100644
--- a/groovy/src/main/resources/interpreter-setting.json
+++ b/groovy/src/main/resources/interpreter-setting.json
@@ -11,6 +11,10 @@
         "description": "The path for custom groovy classes location. If empty `./interpreter/groovy/classes`",
         "type": "textarea"
       }
+    },
+    "editor": {
+      "editOnDblClick": false,
+      "completionSupport": false
     }
   }
 ]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a7bf3ac4/hbase/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/hbase/src/main/resources/interpreter-setting.json b/hbase/src/main/resources/interpreter-setting.json
index 28dedcc..c5d89f0 100644
--- a/hbase/src/main/resources/interpreter-setting.json
+++ b/hbase/src/main/resources/interpreter-setting.json
@@ -25,7 +25,8 @@
       }
     },
     "editor": {
-      "editOnDblClick": false
+      "editOnDblClick": false,
+      "completionSupport": false
     }
   }
 ]

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a7bf3ac4/ignite/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/ignite/src/main/resources/interpreter-setting.json b/ignite/src/main/resources/interpreter-setting.json
index 2342a90..3601e15 100644
--- a/ignite/src/main/resources/interpreter-setting.json
+++ b/ignite/src/main/resources/interpreter-setting.json
@@ -32,6 +32,10 @@
         "description": "Peer class loading enabled. True or false",
         "type": "checkbox"
       }
+    },
+    "editor": {
+      "editOnDblClick": false,
+      "completionSupport": false
     }
   },
   { 
@@ -46,6 +50,10 @@
         "description": "Ignite JDBC connection URL.",
         "type": "string"
         }
-    }   
+    },
+    "editor": {
+      "editOnDblClick": false,
+      "completionSupport": false
+    }
   }
 ]

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a7bf3ac4/jdbc/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/jdbc/src/main/resources/interpreter-setting.json b/jdbc/src/main/resources/interpreter-setting.json
index abbc1cf..bedd9df 100644
--- a/jdbc/src/main/resources/interpreter-setting.json
+++ b/jdbc/src/main/resources/interpreter-setting.json
@@ -105,7 +105,8 @@
     },
     "editor": {
       "language": "sql",
-      "editOnDblClick": false
+      "editOnDblClick": false,
+      "completionSupport": true
     }
   }
 ]

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a7bf3ac4/kylin/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/kylin/src/main/resources/interpreter-setting.json b/kylin/src/main/resources/interpreter-setting.json
index f5f79f9..88cf369 100644
--- a/kylin/src/main/resources/interpreter-setting.json
+++ b/kylin/src/main/resources/interpreter-setting.json
@@ -56,7 +56,8 @@
     },
     "editor": {
       "language": "sql",
-      "editOnDblClick": false
+      "editOnDblClick": false,
+      "completionSupport": true
     }
   }
 ]

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a7bf3ac4/lens/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/lens/src/main/resources/interpreter-setting.json b/lens/src/main/resources/interpreter-setting.json
index 5d345e6..03fda56 100644
--- a/lens/src/main/resources/interpreter-setting.json
+++ b/lens/src/main/resources/interpreter-setting.json
@@ -53,6 +53,10 @@
         "description": "Hadoop cluster username",
         "type": "string"
       }
+    },
+    "editor": {
+      "editOnDblClick": false,
+      "completionSupport": false
     }
   }
 ]

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a7bf3ac4/livy/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/livy/src/main/resources/interpreter-setting.json b/livy/src/main/resources/interpreter-setting.json
index d096c46..8b9b906 100644
--- a/livy/src/main/resources/interpreter-setting.json
+++ b/livy/src/main/resources/interpreter-setting.json
@@ -128,7 +128,8 @@
     "editor": {
       "language": "scala",
       "editOnDblClick": false,
-      "completionKey": "TAB"
+      "completionKey": "TAB",
+      "completionSupport": true
     }
   },
   {
@@ -168,7 +169,8 @@
     "editor": {
       "language": "sql",
       "editOnDblClick": false,
-      "completionKey": "TAB"
+      "completionKey": "TAB",
+      "completionSupport": true
     }
   },
   {
@@ -189,7 +191,8 @@
     "editor": {
       "language": "python",
       "editOnDblClick": false,
-      "completionKey": "TAB"
+      "completionKey": "TAB",
+      "completionSupport": true
     }
   },
   {
@@ -210,7 +213,8 @@
     "editor": {
       "language": "python",
       "editOnDblClick": false,
-      "completionKey": "TAB"
+      "completionKey": "TAB",
+      "completionSupport": true
     }
   },
   {
@@ -231,7 +235,8 @@
     "editor": {
       "language": "r",
       "editOnDblClick": false,
-      "completionKey": "TAB"
+      "completionKey": "TAB",
+      "completionSupport": true
     }
   },
   {

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a7bf3ac4/markdown/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/markdown/src/main/resources/interpreter-setting.json b/markdown/src/main/resources/interpreter-setting.json
index 9819210..d2a59c8 100644
--- a/markdown/src/main/resources/interpreter-setting.json
+++ b/markdown/src/main/resources/interpreter-setting.json
@@ -14,7 +14,8 @@
     },
     "editor": {
       "language": "markdown",
-      "editOnDblClick": true
+      "editOnDblClick": true,
+      "completionSupport": false
     }
   }
 ]

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a7bf3ac4/python/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/python/src/main/resources/interpreter-setting.json b/python/src/main/resources/interpreter-setting.json
index f36add3..f1e5e49 100644
--- a/python/src/main/resources/interpreter-setting.json
+++ b/python/src/main/resources/interpreter-setting.json
@@ -27,7 +27,8 @@
     },
     "editor": {
       "language": "python",
-      "editOnDblClick": false
+      "editOnDblClick": false,
+      "completionSupport": true
     }
   },
   {
@@ -51,7 +52,8 @@
     "editor": {
       "language": "python",
       "editOnDblClick": false,
-      "completionKey": "TAB"
+      "completionKey": "TAB",
+      "completionSupport": true
     }
   },
   {
@@ -63,7 +65,8 @@
     "editor":{
       "language": "sql",
       "editOnDblClick": false,
-      "completionKey": "TAB"
+      "completionKey": "TAB",
+      "completionSupport": false
     }
   },
   {
@@ -74,7 +77,8 @@
     },
     "editor": {
       "language": "sh",
-      "editOnDblClick": false
+      "editOnDblClick": false,
+      "completionSupport": false
     }
   },
   {
@@ -85,7 +89,8 @@
     },
     "editor":{
       "language": "sh",
-      "editOnDblClick": false
+      "editOnDblClick": false,
+      "completionSupport": false
     }
   }
 ]

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a7bf3ac4/sap/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/sap/src/main/resources/interpreter-setting.json b/sap/src/main/resources/interpreter-setting.json
index cb5cf94..9ab78b8 100644
--- a/sap/src/main/resources/interpreter-setting.json
+++ b/sap/src/main/resources/interpreter-setting.json
@@ -36,7 +36,8 @@
     },
     "editor": {
       "editOnDblClick": false,
-      "completionKey": "TAB"
+      "completionKey": "TAB",
+      "completionSupport": true
     }
   }
 ]

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a7bf3ac4/shell/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/shell/src/main/resources/interpreter-setting.json b/shell/src/main/resources/interpreter-setting.json
index a332134..b6784b9 100644
--- a/shell/src/main/resources/interpreter-setting.json
+++ b/shell/src/main/resources/interpreter-setting.json
@@ -49,7 +49,8 @@
     },
     "editor": {
       "language": "sh",
-      "editOnDblClick": false
+      "editOnDblClick": false,
+      "completionSupport": false
     }
   }
 ]

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a7bf3ac4/spark/interpreter/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/spark/interpreter/src/main/resources/interpreter-setting.json b/spark/interpreter/src/main/resources/interpreter-setting.json
index db3aebb..30ae737 100644
--- a/spark/interpreter/src/main/resources/interpreter-setting.json
+++ b/spark/interpreter/src/main/resources/interpreter-setting.json
@@ -86,7 +86,8 @@
     "editor": {
       "language": "scala",
       "editOnDblClick": false,
-      "completionKey": "TAB"
+      "completionKey": "TAB",
+      "completionSupport": true
     }
   },
   {
@@ -133,7 +134,8 @@
     "editor": {
       "language": "sql",
       "editOnDblClick": false,
-      "completionKey": "TAB"
+      "completionKey": "TAB",
+      "completionSupport": true
     }
   },
   {
@@ -159,7 +161,8 @@
     "editor": {
       "language": "scala",
       "editOnDblClick": false,
-      "completionKey": "TAB"
+      "completionKey": "TAB",
+      "completionSupport": true
     }
   },
   {
@@ -185,7 +188,8 @@
     "editor": {
       "language": "python",
       "editOnDblClick": false,
-      "completionKey": "TAB"
+      "completionKey": "TAB",
+      "completionSupport": true
     }
   },
   {
@@ -195,7 +199,8 @@
     "properties": {},
     "editor": {
       "language": "python",
-      "editOnDblClick": false
+      "editOnDblClick": false,
+      "completionSupport": true
     }
   },
   {
@@ -234,7 +239,8 @@
     },
     "editor": {
       "language": "r",
-      "editOnDblClick": false
+      "editOnDblClick": false,
+      "completionSupport": false
     }
   }
 ]

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a7bf3ac4/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
----------------------------------------------------------------------
diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
b/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
index e51fc53..1e1e997 100644
--- a/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
+++ b/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
@@ -1393,7 +1393,13 @@ public class NotebookServer extends WebSocketServlet
     }
 
     final Note note = notebook.getNote(getOpenNoteId(conn));
-    List<InterpreterCompletion> candidates = note.completion(paragraphId, buffer, cursor);
+    List<InterpreterCompletion> candidates;
+    try {
+      candidates = note.completion(paragraphId, buffer, cursor);
+    } catch (RuntimeException e) {
+      LOG.info("Fail to get completion", e);
+      candidates = new ArrayList<>();
+    }
     resp.put("completions", candidates);
     conn.send(serializeMessage(resp));
   }

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a7bf3ac4/zeppelin-web/bower.json
----------------------------------------------------------------------
diff --git a/zeppelin-web/bower.json b/zeppelin-web/bower.json
index 3de9f56..4d0d028 100644
--- a/zeppelin-web/bower.json
+++ b/zeppelin-web/bower.json
@@ -14,7 +14,7 @@
     "angular-resource": "1.5.7",
     "angular-bootstrap": "~2.5.0",
     "angular-websocket": "~1.0.13",
-    "ace-builds": "1.2.7",
+    "ace-builds": "1.3.2",
     "angular-ui-ace": "0.1.3",
     "jquery.scrollTo": "~1.4.13",
     "nvd3": "~1.8.5",
@@ -55,7 +55,7 @@
         "src-noconflict/ext-language_tools.js",
         "src-noconflict/theme-chrome.js"
       ],
-      "version": "1.2.7",
+      "version": "1.3.2",
       "name": "ace-builds"
     },
     "highlightjs": {
@@ -68,7 +68,7 @@
     }
   },
   "resolutions": {
-    "ace-builds": "1.2.7",
+    "ace-builds": "1.3.2",
     "angular": ">=1.5.0 <1.6"
   }
 }

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a7bf3ac4/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
index ee17130..41474be 100644
--- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
+++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
@@ -34,6 +34,7 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams,
$locat
   'ngInject';
 
   let ANGULAR_FUNCTION_OBJECT_NAME_PREFIX = '_Z_ANGULAR_FUNC_';
+  let completionListLength = undefined;
   $rootScope.keys = Object.keys;
   $scope.parentNote = null;
   $scope.paragraph = {};
@@ -750,6 +751,16 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams,
$locat
         // not applying emacs key binding while the binding override Ctrl-v. default behavior
of paste text on windows.
       }
 
+      $scope.$on('completionListLength', function(event, data) {
+        completionListLength = data;
+      });
+
+      $scope.$on('callCompletion', function(event, data) {
+        if($scope.paragraphFocused) {
+          websocketMsgSrv.completion($scope.paragraph.id, data.buf, data.pos);
+        }
+      });
+
       let remoteCompleter = {
         getCompletions: function(editor, session, pos, prefix, callback) {
           let langTools = ace.require('ace/ext/language_tools');
@@ -774,7 +785,7 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams,
$locat
           pos = session.getTextRange(new Range(0, 0, pos.row, pos.column)).length;
           let buf = session.getValue();
 
-          websocketMsgSrv.completion($scope.paragraph.id, buf, pos);
+          $rootScope.$broadcast('callCompletion', {buf: buf, pos: pos});
 
           $scope.$on('completionList', function(event, data) {
             let computeCaption = function(value, meta) {
@@ -805,6 +816,7 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams,
$locat
                   });
                 }
               }
+              $rootScope.$broadcast('completionListLength', completions.length);
               callback(null, completions);
             }
           });
@@ -963,8 +975,76 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams,
$locat
     }
   };
 
+  // ref: https://github.com/ajaxorg/ace/blob/5021d0193d9f2bba5a978d0b1d7a4f73d18ce713/lib/ace/autocomplete.js#L454
+  const completionSupportWithoutBackend = function(str) {
+    let matches;
+    if (str.length > this.filterText && str.lastIndexOf(
+        this.filterText, 0) === 0) {
+      matches = this.filtered;
+    } else {
+      matches = this.all;
+    }
+
+    this.filterText = str;
+    matches = this.filterCompletions(matches, this.filterText);
+    matches = matches.sort(function(a, b) {
+      return b.exactMatch - a.exactMatch || b.score - a.score;
+    });
+    let prev = null;
+
+    matches = matches.filter(function(item) {
+      let caption = item.snippet || item.caption || item.value;
+      if (caption === prev) {
+        return false;
+      }
+      prev = caption;
+      return true;
+    });
+    this.filtered = matches;
+  };
+
+  const completionSupportWithBackend = function(str) {
+    let matches;
+    if (str.length > this.filterText && str.lastIndexOf(
+        this.filterText, 0) === 0) {
+      matches = this.filtered;
+    } else {
+      matches = this.all;
+    }
+    this.filterText = str;
+    matches = this.filterCompletions(matches, this.filterText);
+    matches = matches.sort(function(a, b) {
+      return b.exactMatch - a.exactMatch || b.score - a.score;
+    });
+    let prev = null;
+
+    matches = matches.filter(function(item) {
+      if (!_.isEmpty(item.meta)) {
+        if (completionListLength !== 0) {
+          return false;
+        }
+      }
+      let caption = item.snippet || item.caption || item.value;
+      if (caption === prev) {
+        return false;
+      }
+      prev = caption;
+      return true;
+    });
+    this.filtered = matches;
+    completionListLength = undefined;
+  };
+
   const handleFocus = function(focused, isDigestPass) {
     $scope.paragraphFocused = focused;
+    if (focused) {
+      let filteredList = ace.require('ace/autocomplete').FilteredList;
+      if ($scope.paragraph.config.editorSetting.completionSupport) {
+        filteredList.prototype.setFilter = completionSupportWithBackend;
+      } else {
+        filteredList.prototype.setFilter = completionSupportWithoutBackend;
+      }
+    }
 
     if ($scope.editor) {
       $scope.editor.setHighlightActiveLine(focused);


Mime
View raw message