This commit is contained in:
Johannes Rieken 2016-08-17 11:56:34 +02:00
parent 08eeba4353
commit 1a5e5e43c5

View file

@ -156,7 +156,7 @@ export class SuggestModel implements IDisposable {
private requestPromise: TPromise<void>; private requestPromise: TPromise<void>;
private context: Context; private context: Context;
private raw: ISuggestionItem[]; private suggestionItems: ISuggestionItem[];
private completionModel: CompletionModel; private completionModel: CompletionModel;
private incomplete: boolean; private incomplete: boolean;
@ -176,7 +176,7 @@ export class SuggestModel implements IDisposable {
this.state = State.Idle; this.state = State.Idle;
this.triggerAutoSuggestPromise = null; this.triggerAutoSuggestPromise = null;
this.requestPromise = null; this.requestPromise = null;
this.raw = null; this.suggestionItems = null;
this.completionModel = null; this.completionModel = null;
this.incomplete = false; this.incomplete = false;
this.context = null; this.context = null;
@ -204,7 +204,7 @@ export class SuggestModel implements IDisposable {
} }
this.state = State.Idle; this.state = State.Idle;
this.raw = null; this.suggestionItems = null;
this.completionModel = null; this.completionModel = null;
this.incomplete = false; this.incomplete = false;
this.context = null; this.context = null;
@ -258,7 +258,7 @@ export class SuggestModel implements IDisposable {
}); });
} }
} else if (this.raw && this.incomplete) { } else if (this.suggestionItems && this.incomplete) {
this.trigger(this.state === State.Auto, true); this.trigger(this.state === State.Auto, true);
} else { } else {
this.onNewContext(ctx); this.onNewContext(ctx);
@ -301,7 +301,7 @@ export class SuggestModel implements IDisposable {
this.context = ctx; this.context = ctx;
this.requestPromise = provideSuggestionItems(model, this.editor.getPosition(), this.requestPromise = provideSuggestionItems(model, this.editor.getPosition(),
this.editor.getConfiguration().contribInfo.snippetSuggestions, onlyFrom).then(all => { this.editor.getConfiguration().contribInfo.snippetSuggestions, onlyFrom).then(items => {
this.requestPromise = null; this.requestPromise = null;
@ -309,16 +309,15 @@ export class SuggestModel implements IDisposable {
return; return;
} }
this.raw = all;
this.incomplete = all.some(result => result.container.incomplete);
const model = this.editor.getModel(); const model = this.editor.getModel();
if (!model) { if (!model) {
return; return;
} }
this.suggestionItems = items;
this.incomplete = items.some(result => result.container.incomplete);
this.onNewContext(new Context(model, this.editor.getPosition(), auto)); this.onNewContext(new Context(model, this.editor.getPosition(), auto));
}).then(null, onUnexpectedError); }).then(null, onUnexpectedError);
} }
@ -333,11 +332,11 @@ export class SuggestModel implements IDisposable {
return; return;
} }
if (this.raw) { if (this.suggestionItems) {
let auto = this.isAutoSuggest(); let auto = this.isAutoSuggest();
let isFrozen = false; let isFrozen = false;
if (this.completionModel && this.completionModel.raw === this.raw) { if (this.completionModel && this.completionModel.raw === this.suggestionItems) {
const oldLineContext = this.completionModel.lineContext; const oldLineContext = this.completionModel.lineContext;
this.completionModel.lineContext = { this.completionModel.lineContext = {
leadingLineContent: ctx.lineContentBefore, leadingLineContent: ctx.lineContentBefore,
@ -351,7 +350,7 @@ export class SuggestModel implements IDisposable {
isFrozen = true; isFrozen = true;
} }
} else { } else {
this.completionModel = new CompletionModel(this.raw, ctx.lineContentBefore); this.completionModel = new CompletionModel(this.suggestionItems, ctx.lineContentBefore);
} }
this._onDidSuggest.fire({ this._onDidSuggest.fire({
@ -363,7 +362,7 @@ export class SuggestModel implements IDisposable {
} }
accept(suggestion: ISuggestion, overwriteBefore: number, overwriteAfter: number): boolean { accept(suggestion: ISuggestion, overwriteBefore: number, overwriteAfter: number): boolean {
if (this.raw === null) { if (this.suggestionItems === null) {
return false; return false;
} }