mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 17:48:56 +01:00
Avoid creating execution state listener for every cell. (#177025)
This commit is contained in:
@@ -33,6 +33,7 @@ import { CellKind, ICell, INotebookSearchOptions, ISelectionState, NotebookCells
|
||||
import { cellIndexesToRanges, cellRangesToIndexes, ICellRange, reduceCellRanges } from 'vs/workbench/contrib/notebook/common/notebookRange';
|
||||
import { NotebookLayoutInfo, NotebookMetadataChangedEvent } from 'vs/workbench/contrib/notebook/browser/notebookViewEvents';
|
||||
import { CellFindMatchModel } from 'vs/workbench/contrib/notebook/browser/contrib/find/findModel';
|
||||
import { INotebookExecutionStateService } from 'vs/workbench/contrib/notebook/common/notebookExecutionStateService';
|
||||
|
||||
const invalidFunc = () => { throw new Error(`Invalid change accessor`); };
|
||||
|
||||
@@ -196,6 +197,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD
|
||||
@IBulkEditService private readonly _bulkEditService: IBulkEditService,
|
||||
@IUndoRedoService private readonly _undoService: IUndoRedoService,
|
||||
@ITextModelService private readonly _textModelService: ITextModelService,
|
||||
@INotebookExecutionStateService notebookExecutionStateService: INotebookExecutionStateService,
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -318,6 +320,13 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD
|
||||
}
|
||||
}));
|
||||
|
||||
this._register(notebookExecutionStateService.onDidChangeCellExecution(e => {
|
||||
const cell = this.getCellByHandle(e.cellHandle);
|
||||
|
||||
if (cell instanceof CodeCellViewModel) {
|
||||
cell.updateExecutionState(e);
|
||||
}
|
||||
}));
|
||||
|
||||
this._register(this._selectionCollection.onDidChangeSelection(e => {
|
||||
this._onDidChangeSelection.fire(e);
|
||||
|
||||
Reference in New Issue
Block a user