diff --git a/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.ts b/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.ts index 0671f846db6..087f5bd3e82 100644 --- a/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.ts +++ b/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.ts @@ -94,7 +94,8 @@ export class NotebookOutlineEntryFactory { return entries; } - public async cacheSymbols(textModel: ITextModel, outlineModelService: IOutlineModelService, cancelToken: CancellationToken) { + public async cacheSymbols(cell: ICellViewModel, outlineModelService: IOutlineModelService, cancelToken: CancellationToken) { + const textModel = await cell.resolveTextModel(); const outlineModel = await outlineModelService.getOrCreate(textModel, cancelToken); const entries = createOutlineEntries(outlineModel.getTopLevelSymbols(), 7); this.cellOutlineEntryCache[textModel.id] = entries; diff --git a/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineProvider.ts b/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineProvider.ts index 7e5f1d22b66..f87308334f0 100644 --- a/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineProvider.ts +++ b/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineProvider.ts @@ -107,11 +107,10 @@ export class NotebookCellOutlineProvider { this._entries.length = 0; if (notebookCells) { const promises: Promise[] = []; - for (const cell of notebookCells) { - if (cell.textModel) { - // gather all symbols asynchronously - promises.push(this._outlineEntryFactory.cacheSymbols(cell.textModel, this._outlineModelService, cancelToken)); - } + // limit the number of cells so that we don't resolve an excessive amount of text models + for (const cell of notebookCells.slice(0, 100)) { + // gather all symbols asynchronously + promises.push(this._outlineEntryFactory.cacheSymbols(cell, this._outlineModelService, cancelToken)); } await Promise.allSettled(promises); }