Browse Source

[core] Add support for session autocompleters to Ace

The completers in Ace are bound to the editors which causes problems if there are many editors in one page. With this change completers can also be added to the individual sessions.
Johan Ahlen 10 năm trước cách đây
mục cha
commit
246c7f4

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/ace/ace.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/ace/ext-language_tools.js


+ 2 - 2
tools/ace-editor/lib/ace/autocomplete.js

@@ -235,8 +235,8 @@ var Autocomplete = function() {
         this.base.$insertRight = true;
         this.base.$insertRight = true;
 
 
         var matches = [];
         var matches = [];
-        var total = editor.completers.length;
-        editor.completers.forEach(function(completer, i) {
+        var total = editor.completers.length + session.getCompleters().length;
+        editor.completers.concat(session.getCompleters()).forEach(function(completer, i) {
             completer.getCompletions(editor, session, pos, prefix, function(err, results) {
             completer.getCompletions(editor, session, pos, prefix, function(err, results) {
                 if (!err)
                 if (!err)
                     matches = matches.concat(results);
                     matches = matches.concat(results);

+ 14 - 0
tools/ace-editor/lib/ace/edit_session.js

@@ -957,6 +957,20 @@ var EditSession = function(text, mode) {
         }
         }
     };
     };
 
 
+    this.$completers = [];
+
+    /**
+     * Sets the completers to be used for this session only. Each completer should provide a getCompletions function (see language_tools)
+     * @param {Object[]} completers
+     */
+    this.setCompleters = function(completers) {
+        this.$completers = completers;
+    };
+
+    this.getCompleters = function() {
+        return this.$completers;
+    };
+
     this.$stopWorker = function() {
     this.$stopWorker = function() {
         if (this.$worker) {
         if (this.$worker) {
             this.$worker.terminate();
             this.$worker.terminate();

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác