Don't block on fetchCallStack requests
This commit is contained in:
parent
48c3582ad4
commit
c140ded6c8
1 changed files with 34 additions and 24 deletions
|
@ -10,7 +10,7 @@ import { isEqual } from 'vs/base/common/resources';
|
|||
import { URI } from 'vs/base/common/uri';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { Extensions as WorkbenchExtensions, IWorkbenchContribution, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
|
||||
import { IDebugService } from 'vs/workbench/contrib/debug/common/debug';
|
||||
import { IDebugService, IThread } from 'vs/workbench/contrib/debug/common/debug';
|
||||
import { Thread } from 'vs/workbench/contrib/debug/common/debugModel';
|
||||
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
|
||||
import { CellEditType, CellUri, NotebookCellsChangeType } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
|
@ -104,20 +104,18 @@ class NotebookCellPausing extends Disposable implements IWorkbenchContribution {
|
|||
private readonly _pausedCells = new Set<string>();
|
||||
|
||||
constructor(
|
||||
@IDebugService _debugService: IDebugService,
|
||||
@IDebugService private readonly _debugService: IDebugService,
|
||||
@INotebookService private readonly _notebookService: INotebookService
|
||||
) {
|
||||
super();
|
||||
|
||||
this._register(_debugService.getModel().onDidChangeCallStack(async () => {
|
||||
const newPausedCells = new Set<string>();
|
||||
for (const session of _debugService.getModel().getSessions()) {
|
||||
for (const thread of session.getAllThreads()) {
|
||||
const callStack = thread.getCallStack();
|
||||
if (!callStack.length) {
|
||||
await (thread as Thread).fetchCallStack();
|
||||
this._register(_debugService.getModel().onDidChangeCallStack(this.onDidChangeCallStack, this));
|
||||
}
|
||||
|
||||
private async onDidChangeCallStack(): Promise<void> {
|
||||
const newPausedCells = new Set<string>();
|
||||
|
||||
const updateForThread = (thread: IThread): void => {
|
||||
thread.getCallStack().forEach(sf => {
|
||||
const parsed = CellUri.parse(sf.source.uri);
|
||||
if (parsed) {
|
||||
|
@ -125,9 +123,22 @@ class NotebookCellPausing extends Disposable implements IWorkbenchContribution {
|
|||
this.editIsPaused(sf.source.uri, true);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const promises: Promise<void>[] = [];
|
||||
for (const session of this._debugService.getModel().getSessions()) {
|
||||
for (const thread of session.getAllThreads()) {
|
||||
const callStack = thread.getCallStack();
|
||||
if (callStack.length) {
|
||||
updateForThread(thread);
|
||||
} else {
|
||||
promises.push(
|
||||
(thread as Thread).fetchCallStack().then(() => updateForThread(thread)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await Promise.all(promises);
|
||||
for (const uri of this._pausedCells) {
|
||||
if (!newPausedCells.has(uri)) {
|
||||
this.editIsPaused(URI.parse(uri), false);
|
||||
|
@ -136,7 +147,6 @@ class NotebookCellPausing extends Disposable implements IWorkbenchContribution {
|
|||
}
|
||||
|
||||
newPausedCells.forEach(cell => this._pausedCells.add(cell));
|
||||
}));
|
||||
}
|
||||
|
||||
private editIsPaused(cellUri: URI, isPaused: boolean) {
|
||||
|
|
Loading…
Reference in a new issue