Skip to content

Commit d087cf3

Browse files
authored
Improve typing performance by not updating widget when nothing changed (microsoft#178167)
1 parent d484f15 commit d087cf3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/vs/editor/contrib/inlineCompletions/browser/inlineSuggestionHintsWidget.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { h } from 'vs/base/browser/dom';
77
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
88
import { KeybindingLabel, unthemedKeybindingLabelOptions } from 'vs/base/browser/ui/keybindingLabel/keybindingLabel';
99
import { Action, IAction, Separator } from 'vs/base/common/actions';
10+
import { equals } from 'vs/base/common/arrays';
1011
import { RunOnceScheduler } from 'vs/base/common/async';
1112
import { Codicon } from 'vs/base/common/codicons';
1213
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
@@ -154,6 +155,10 @@ export class InlineSuggestionHintsContentWidget extends Disposable implements IC
154155
this.previousAction.enabled = this.nextAction.enabled = false;
155156
}, 100));
156157

158+
private lastCurrentSuggestionIdx = -1;
159+
private lastSuggestionCount = -1;
160+
private lastCommands: Command[] = [];
161+
157162
constructor(
158163
private readonly editor: ICodeEditor,
159164
private readonly withBorder: boolean,
@@ -186,7 +191,18 @@ export class InlineSuggestionHintsContentWidget extends Disposable implements IC
186191
}
187192

188193
public update(position: Position | null, currentSuggestionIdx: number, suggestionCount: number | undefined, extraCommands: Command[]): void {
194+
if (this.position === position
195+
&& this.lastCurrentSuggestionIdx === currentSuggestionIdx
196+
&& this.lastSuggestionCount === suggestionCount
197+
&& equals(this.lastCommands, extraCommands)) {
198+
// nothing to update
199+
return;
200+
}
201+
189202
this.position = position;
203+
this.lastCurrentSuggestionIdx = currentSuggestionIdx;
204+
this.lastSuggestionCount = suggestionCount ?? -1;
205+
this.lastCommands = extraCommands;
190206

191207
if (suggestionCount !== undefined && suggestionCount > 1) {
192208
this.disableButtonsDebounced.cancel();
@@ -298,6 +314,11 @@ export class CustomizedMenuWorkbenchToolBar extends WorkbenchToolBar {
298314
}
299315

300316
setAdditionalSecondaryActions(actions: IAction[]): void {
317+
if (equals(this.additionalActions, actions, (a, b) => a === b)) {
318+
// don't update if the actions are the same
319+
return;
320+
}
321+
301322
this.additionalActions = actions;
302323
this.updateToolbar();
303324
}

0 commit comments

Comments
 (0)