mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-10 20:44:25 +01:00
resolve cell text models so that we get the symbols even for cells outside the view
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user