提交 eb068a5d 编写于 作者: J Johannes Rieken

fix filtering issue when cursor moved before model was created, #10621

上级 a69082b1
......@@ -42,9 +42,9 @@ export class CompletionModel {
private _filteredItems: CompletionItem[] = undefined;
private _topScoreIdx: number;
constructor(raw: ISuggestionItem[], leadingLineContent: string) {
constructor(raw: ISuggestionItem[], lineContext: LineContext) {
this.raw = raw;
this._lineContext = { leadingLineContent, characterCountDelta: 0 };
this._lineContext = lineContext;
for (let item of raw) {
this._items.push(new CompletionItem(item));
}
......
......@@ -14,7 +14,7 @@ import {TPromise} from 'vs/base/common/winjs.base';
import {ICommonCodeEditor, ICursorSelectionChangedEvent, CursorChangeReason, IModel, IPosition} from 'vs/editor/common/editorCommon';
import {ISuggestSupport, SuggestRegistry} from 'vs/editor/common/modes';
import {ISuggestionItem, provideSuggestionItems} from './suggest';
import {CompletionModel} from './completionModel';
import {CompletionModel, LineContext} from './completionModel';
export interface ICancelEvent {
retrigger: boolean;
......@@ -396,24 +396,24 @@ export class SuggestModel implements IDisposable {
}
if (this.suggestionItems) {
let auto = this.isAutoSuggest();
const auto = this.isAutoSuggest();
const lineContext: LineContext = {
leadingLineContent: ctx.lineContentBefore,
characterCountDelta: this.context ? ctx.column - this.context.column : 0
};
let isFrozen = false;
if (this.completionModel && this.completionModel.raw === this.suggestionItems) {
const oldLineContext = this.completionModel.lineContext;
this.completionModel.lineContext = {
leadingLineContent: ctx.lineContentBefore,
characterCountDelta: this.context
? ctx.column - this.context.column
: 0
};
this.completionModel.lineContext = lineContext;
if (!auto && this.completionModel.items.length === 0) {
this.completionModel.lineContext = oldLineContext;
isFrozen = true;
}
} else {
this.completionModel = new CompletionModel(this.suggestionItems, ctx.lineContentBefore);
this.completionModel = new CompletionModel(this.suggestionItems, lineContext);
}
this._onDidSuggest.fire({
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册