|
7 | 7 | import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
|
8 | 8 | import { ResourceMap } from 'vs/base/common/map';
|
9 | 9 | import { isEqual } from 'vs/base/common/resources';
|
10 |
| -import { URI } from 'vs/base/common/uri'; |
11 | 10 | import { Registry } from 'vs/platform/registry/common/platform';
|
12 | 11 | import { Extensions as WorkbenchExtensions, IWorkbenchContribution, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
|
13 |
| -import { IDebugService, IThread } from 'vs/workbench/contrib/debug/common/debug'; |
14 |
| -import { Thread } from 'vs/workbench/contrib/debug/common/debugModel'; |
| 12 | +import { IDebugService } from 'vs/workbench/contrib/debug/common/debug'; |
15 | 13 | import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
|
16 |
| -import { CellEditType, CellUri, NotebookCellsChangeType } from 'vs/workbench/contrib/notebook/common/notebookCommon'; |
| 14 | +import { CellUri, NotebookCellsChangeType } from 'vs/workbench/contrib/notebook/common/notebookCommon'; |
17 | 15 | import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
|
18 | 16 | import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
|
19 | 17 |
|
@@ -99,67 +97,3 @@ class NotebookBreakpoints extends Disposable implements IWorkbenchContribution {
|
99 | 97 | }
|
100 | 98 |
|
101 | 99 | Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(NotebookBreakpoints, LifecyclePhase.Restored);
|
102 |
| - |
103 |
| -class NotebookCellPausing extends Disposable implements IWorkbenchContribution { |
104 |
| - private readonly _pausedCells = new Set<string>(); |
105 |
| - |
106 |
| - constructor( |
107 |
| - @IDebugService private readonly _debugService: IDebugService, |
108 |
| - @INotebookService private readonly _notebookService: INotebookService |
109 |
| - ) { |
110 |
| - super(); |
111 |
| - |
112 |
| - this._register(_debugService.getModel().onDidChangeCallStack(this.onDidChangeCallStack, this)); |
113 |
| - } |
114 |
| - |
115 |
| - private async onDidChangeCallStack(): Promise<void> { |
116 |
| - const newPausedCells = new Set<string>(); |
117 |
| - |
118 |
| - const updateForThread = (thread: IThread): void => { |
119 |
| - thread.getCallStack().forEach(sf => { |
120 |
| - const parsed = CellUri.parse(sf.source.uri); |
121 |
| - if (parsed) { |
122 |
| - newPausedCells.add(sf.source.uri.toString()); |
123 |
| - this.editIsPaused(sf.source.uri, true); |
124 |
| - } |
125 |
| - }); |
126 |
| - }; |
127 |
| - |
128 |
| - const promises: Promise<void>[] = []; |
129 |
| - for (const session of this._debugService.getModel().getSessions()) { |
130 |
| - for (const thread of session.getAllThreads()) { |
131 |
| - const callStack = thread.getCallStack(); |
132 |
| - if (callStack.length) { |
133 |
| - updateForThread(thread); |
134 |
| - } else { |
135 |
| - promises.push( |
136 |
| - (thread as Thread).fetchCallStack().then(() => updateForThread(thread))); |
137 |
| - } |
138 |
| - } |
139 |
| - } |
140 |
| - |
141 |
| - await Promise.all(promises); |
142 |
| - for (const uri of this._pausedCells) { |
143 |
| - if (!newPausedCells.has(uri)) { |
144 |
| - this.editIsPaused(URI.parse(uri), false); |
145 |
| - this._pausedCells.delete(uri); |
146 |
| - } |
147 |
| - } |
148 |
| - |
149 |
| - newPausedCells.forEach(cell => this._pausedCells.add(cell)); |
150 |
| - } |
151 |
| - |
152 |
| - private editIsPaused(cellUri: URI, isPaused: boolean) { |
153 |
| - const parsed = CellUri.parse(cellUri); |
154 |
| - if (parsed) { |
155 |
| - const notebookModel = this._notebookService.getNotebookTextModel(parsed.notebook); |
156 |
| - notebookModel?.applyEdits([{ |
157 |
| - editType: CellEditType.PartialInternalMetadata, |
158 |
| - handle: parsed.handle, |
159 |
| - internalMetadata: { isPaused }, |
160 |
| - }], true, undefined, () => undefined, undefined); |
161 |
| - } |
162 |
| - } |
163 |
| -} |
164 |
| - |
165 |
| -Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(NotebookCellPausing, LifecyclePhase.Restored); |
0 commit comments