diff options
author | Peng Lyu <penn.lv@gmail.com> | 2022-11-10 20:43:34 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-10 20:43:34 +0300 |
commit | 436a45ed1cfc186b10a4dd59c04f12baa8e8375b (patch) | |
tree | ab9ece5e71f3a393bdffb91b4322a975cd696245 /src | |
parent | fc4a4ceee1e6f0c53c443958166d8d8cca795d61 (diff) |
Debounce the kernel picker update. (#166027)
Diffstat (limited to 'src')
-rw-r--r-- | src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.ts | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.ts b/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.ts index 0c2b00f9ac2..f505de68757 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.ts @@ -49,6 +49,7 @@ function isSourcePick(item: QuickPickInput<IQuickPickItem>): item is SourcePick return 'action' in item; } type KernelQuickPickItem = IQuickPickItem | KernelPick | SourcePick; +const KERNEL_PICKER_UPDATE_DEBOUNCE = 200; registerAction2(class extends Action2 { constructor() { @@ -187,11 +188,15 @@ registerAction2(class extends Action2 { ? nls.localize('prompt.placeholder.change', "Change kernel for '{0}'", labelService.getUriLabel(notebook.uri, { relative: true })) : nls.localize('prompt.placeholder.select', "Select kernel for '{0}'", labelService.getUriLabel(notebook.uri, { relative: true })); - const kernelChangeEventListener = Event.any( - notebookKernelService.onDidChangeSourceActions, - notebookKernelService.onDidAddKernel, - notebookKernelService.onDidRemoveKernel, - notebookKernelService.onDidChangeNotebookAffinity + const kernelChangeEventListener = Event.debounce<void, void>( + Event.any( + notebookKernelService.onDidChangeSourceActions, + notebookKernelService.onDidAddKernel, + notebookKernelService.onDidRemoveKernel, + notebookKernelService.onDidChangeNotebookAffinity + ), + (last, _current) => last, + KERNEL_PICKER_UPDATE_DEBOUNCE )(() => { const currentActiveItems = quickPick.activeItems; const matchResult = notebookKernelService.getMatchingKernel(notebook); @@ -218,7 +223,7 @@ registerAction2(class extends Action2 { quickPick.items = quickPickItemSuggestions.quickPickItems; quickPick.activeItems = activeItems; - }); + }, this); const pick = await new Promise<KernelQuickPickItem>((resolve, reject) => { quickPick.onDidAccept(() => { |