resolve cell text models so that we get the symbols even for cells outside the view

This commit is contained in:
Aaron Munger
2023-09-22 14:49:56 -07:00
parent 1c6fe1ee54
commit ec41ee59eb
2 changed files with 6 additions and 6 deletions
@@ -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;
@@ -107,11 +107,10 @@ export class NotebookCellOutlineProvider {
this._entries.length = 0;
if (notebookCells) {
const promises: Promise<void>[] = [];
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);
}