mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-31 04:35:14 +01:00
Lock SuggestOvertypingCapturer while suggest widget is active
This commit is contained in:
@@ -13,15 +13,12 @@ export class OvertypingCapturer implements IDisposable {
|
||||
private readonly _disposables = new DisposableStore();
|
||||
|
||||
private _lastOvertyped: { value: string; multiline: boolean }[] = [];
|
||||
private _empty: boolean = true;
|
||||
private _locked: boolean = false;
|
||||
|
||||
constructor(editor: ICodeEditor, suggestModel: SuggestModel) {
|
||||
|
||||
this._disposables.add(editor.onWillType(() => {
|
||||
if (!this._empty) {
|
||||
return;
|
||||
}
|
||||
if (!editor.hasModel()) {
|
||||
if (this._locked || !editor.hasModel()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -37,6 +34,9 @@ export class OvertypingCapturer implements IDisposable {
|
||||
}
|
||||
}
|
||||
if (!willOvertype) {
|
||||
if (this._lastOvertyped.length !== 0) {
|
||||
this._lastOvertyped.length = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,18 +50,19 @@ export class OvertypingCapturer implements IDisposable {
|
||||
}
|
||||
this._lastOvertyped[i] = { value: model.getValueInRange(selection), multiline: selection.startLineNumber !== selection.endLineNumber };
|
||||
}
|
||||
this._empty = false;
|
||||
}));
|
||||
|
||||
this._disposables.add(suggestModel.onDidTrigger(e => {
|
||||
this._locked = true;
|
||||
}));
|
||||
|
||||
this._disposables.add(suggestModel.onDidCancel(e => {
|
||||
if (!this._empty && !e.retrigger) {
|
||||
this._empty = true;
|
||||
}
|
||||
this._locked = false;
|
||||
}));
|
||||
}
|
||||
|
||||
getLastOvertypedInfo(idx: number): { value: string; multiline: boolean } | undefined {
|
||||
if (!this._empty && idx >= 0 && idx < this._lastOvertyped.length) {
|
||||
if (idx >= 0 && idx < this._lastOvertyped.length) {
|
||||
return this._lastOvertyped[idx];
|
||||
}
|
||||
return undefined;
|
||||
|
||||
Reference in New Issue
Block a user