mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
ZEPPELIN-3001: Disable ace editor code completion when back-end interpreter support completion
Change-Id: I315ff17c6f50ad3ad912a38366833823e5241574
This commit is contained in:
parent
2a5960bd50
commit
adaabcbf92
2 changed files with 43 additions and 1 deletions
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -709,6 +709,42 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams, $locat
|
|||
$scope.aceLoaded = function(_editor) {
|
||||
let langTools = ace.require('ace/ext/language_tools');
|
||||
let Range = ace.require('ace/range').Range;
|
||||
let filteredList = ace.require('ace/autocomplete').FilteredList;
|
||||
|
||||
// ref: https://github.com/ajaxorg/ace/blob/5021d0193d9f2bba5a978d0b1d7a4f73d18ce713/lib/ace/autocomplete.js#L454
|
||||
filteredList.prototype.setFilter = 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;
|
||||
|
||||
// Meta empty means item is supplied from backend
|
||||
let isMetaEmpty = false;
|
||||
if (matches[0] !== undefined && matches[0]['meta'] === '') {
|
||||
isMetaEmpty = true;
|
||||
}
|
||||
matches = matches.filter(function(item) {
|
||||
if (isMetaEmpty && item.meta !== '') {
|
||||
return false;
|
||||
}
|
||||
let caption = item.snippet || item.caption || item.value;
|
||||
if (caption === prev) {
|
||||
return false;
|
||||
}
|
||||
prev = caption;
|
||||
return true;
|
||||
});
|
||||
this.filtered = matches;
|
||||
};
|
||||
|
||||
_editor.$blockScrolling = Infinity;
|
||||
$scope.editor = _editor;
|
||||
|
|
|
|||
Loading…
Reference in a new issue