Skip to content

Commit f41eccd

Browse files
authored
Debounce notebook outline updates during execution (microsoft#210004)
1 parent 7eba2d2 commit f41eccd

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineProvider.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { IMarkerService } from 'vs/platform/markers/common/markers';
1212
import { IThemeService } from 'vs/platform/theme/common/themeService';
1313
import { IActiveNotebookEditor, ICellViewModel, INotebookEditor, INotebookViewCellsUpdateEvent } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
1414
import { CellKind, NotebookSetting } from 'vs/workbench/contrib/notebook/common/notebookCommon';
15-
import { INotebookExecutionStateService, NotebookExecutionType } from 'vs/workbench/contrib/notebook/common/notebookExecutionStateService';
15+
import { INotebookExecutionStateService, NotebookExecutionType, type ICellExecutionStateChangedEvent, type IExecutionStateChangedEvent } from 'vs/workbench/contrib/notebook/common/notebookExecutionStateService';
1616
import { OutlineChangeEvent, OutlineConfigKeys, OutlineTarget } from 'vs/workbench/services/outline/browser/outline';
1717
import { OutlineEntry } from './OutlineEntry';
1818
import { IOutlineModelService } from 'vs/editor/contrib/documentSymbols/browser/outlineModel';
@@ -83,11 +83,16 @@ export class NotebookCellOutlineProvider {
8383
this._onDidChange.fire({});
8484
}));
8585

86-
this._disposables.add(notebookExecutionStateService.onDidChangeExecution(e => {
87-
if (e.type === NotebookExecutionType.cell && !!this._editor.textModel && e.affectsNotebook(this._editor.textModel?.uri)) {
88-
this._recomputeState();
89-
}
90-
}));
86+
this._disposables.add(
87+
Event.debounce<ICellExecutionStateChangedEvent | IExecutionStateChangedEvent>(
88+
notebookExecutionStateService.onDidChangeExecution,
89+
(last, _current) => last ?? _current,
90+
200)(e => {
91+
if (e.type === NotebookExecutionType.cell && !!this._editor.textModel && e.affectsNotebook(this._editor.textModel?.uri)) {
92+
this._recomputeState();
93+
}
94+
})
95+
);
9196

9297
this._recomputeState();
9398
}

0 commit comments

Comments
 (0)