make default suggestion if there is no suggestion from back-end.

Change-Id: Ic53c4c8ceb62d5e274307df360c35d351b7814a6
This commit is contained in:
Prabhjyot Singh 2018-03-22 13:01:53 +05:30
parent 97f594dc85
commit 701f93f854
No known key found for this signature in database
GPG key ID: E8B414FA26357220

View file

@ -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,10 @@ 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;
});
let remoteCompleter = {
getCompletions: function(editor, session, pos, prefix, callback) {
let langTools = ace.require('ace/ext/language_tools');
@ -805,6 +810,7 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams, $locat
});
}
}
$rootScope.$broadcast('completionListLength', completions.length);
callback(null, completions);
}
});
@ -1008,7 +1014,9 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams, $locat
matches = matches.filter(function(item) {
if (item.meta !== '') {
return false;
if (completionListLength !== 0) {
return false;
}
}
let caption = item.snippet || item.caption || item.value;
if (caption === prev) {
@ -1018,6 +1026,7 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams, $locat
return true;
});
this.filtered = matches;
completionListLength = undefined;
};
const handleFocus = function(focused, isDigestPass) {