Don't block on fetchCallStack requests
This commit is contained in:
parent
48c3582ad4
commit
c140ded6c8
|
@ -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,39 +104,49 @@ 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));
|
||||
}
|
||||
|
||||
thread.getCallStack().forEach(sf => {
|
||||
const parsed = CellUri.parse(sf.source.uri);
|
||||
if (parsed) {
|
||||
newPausedCells.add(sf.source.uri.toString());
|
||||
this.editIsPaused(sf.source.uri, true);
|
||||
}
|
||||
});
|
||||
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) {
|
||||
newPausedCells.add(sf.source.uri.toString());
|
||||
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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const uri of this._pausedCells) {
|
||||
if (!newPausedCells.has(uri)) {
|
||||
this.editIsPaused(URI.parse(uri), false);
|
||||
this._pausedCells.delete(uri);
|
||||
}
|
||||
await Promise.all(promises);
|
||||
for (const uri of this._pausedCells) {
|
||||
if (!newPausedCells.has(uri)) {
|
||||
this.editIsPaused(URI.parse(uri), false);
|
||||
this._pausedCells.delete(uri);
|
||||
}
|
||||
}
|
||||
|
||||
newPausedCells.forEach(cell => this._pausedCells.add(cell));
|
||||
}));
|
||||
newPausedCells.forEach(cell => this._pausedCells.add(cell));
|
||||
}
|
||||
|
||||
private editIsPaused(cellUri: URI, isPaused: boolean) {
|
||||
|
|
Loading…
Reference in a new issue