提交 7bf49d80 编写于 作者: J Joao Moreno

suggest: finally, narrow with refresh

上级 0bed75df
......@@ -281,15 +281,16 @@ export class SuggestModel implements IDisposable {
}
public trigger(auto: boolean, triggerCharacter?: string, retrigger: boolean = false, groups?: ISuggestSupport[][]): void {
var model = this.editor.getModel();
var characterTriggered = !!triggerCharacter;
if (!groups) {
groups = SuggestRegistry.orderedGroups(model);
}
const model = this.editor.getModel();
const characterTriggered = !!triggerCharacter;
groups = groups || SuggestRegistry.orderedGroups(model);
if (groups.length === 0) {
return;
}
var ctx = new Context(this.editor, auto);
const ctx = new Context(this.editor, auto);
if (!ctx.isInEditableRange) {
return;
}
......@@ -302,7 +303,7 @@ export class SuggestModel implements IDisposable {
// Capture context when request was sent
this.context = ctx;
var position = this.editor.getPosition();
const position = this.editor.getPosition();
this.requestPromise = suggest(model, position, triggerCharacter, groups).then(all => {
this.requestPromise = null;
......@@ -329,7 +330,7 @@ export class SuggestModel implements IDisposable {
return;
}
if (this.raw) { // TODO@Joao: is this ever false?
if (this.raw) {
this._onDidSuggest.fire({ suggestions: this.raw, currentWord: ctx.wordBefore, auto: this.isAutoSuggest() });
}
}
......
......@@ -114,7 +114,7 @@ class CompletionModel {
private groups: CompletionGroup[];
constructor(raw: ISuggestResult2[][], public currentWord: string) {
constructor(public raw: ISuggestResult2[][], public currentWord: string) {
this.incomplete = false;
this.size = 0;
......@@ -597,13 +597,22 @@ export class SuggestWidget implements EditorBrowser.IContentWidget, IDisposable
}
}
private onDidSuggest(e: ISuggestEvent) {
private onDidSuggest(e: ISuggestEvent): void {
this.isLoading = false;
clearTimeout(this.loadingTimeout);
const model = new CompletionModel(e.suggestions, e.currentWord);
let model: CompletionModel = this.tree.getInput();
let promise: TPromise<void>;
this.tree.setInput(model).done(() => {
if (model && model.raw === e.suggestions) {
model.currentWord = e.currentWord;
promise = this.tree.refresh();
} else {
model = new CompletionModel(e.suggestions, e.currentWord);
promise = this.tree.setInput(model);
}
promise.done(() => {
const navigator = this.tree.getNavigator();
const currentWord = e.currentWord;
const currentWordLowerCase = currentWord.toLowerCase();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册