parent
ab8e743520
commit
5673802238
1 changed files with 28 additions and 1 deletions
|
@ -7,21 +7,25 @@
|
||||||
import { RunOnceScheduler } from 'vs/base/common/async';
|
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||||
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
|
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
|
||||||
import { ResourceMap } from 'vs/base/common/map';
|
import { ResourceMap } from 'vs/base/common/map';
|
||||||
|
import { Schemas } from 'vs/base/common/network';
|
||||||
import { isEqual } from 'vs/base/common/resources';
|
import { isEqual } from 'vs/base/common/resources';
|
||||||
import { URI } from 'vs/base/common/uri';
|
import { URI } from 'vs/base/common/uri';
|
||||||
import { Registry } from 'vs/platform/registry/common/platform';
|
import { Registry } from 'vs/platform/registry/common/platform';
|
||||||
import { Extensions as WorkbenchExtensions, IWorkbenchContribution, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
|
import { Extensions as WorkbenchExtensions, IWorkbenchContribution, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
|
||||||
import { IDebugService, State } from 'vs/workbench/contrib/debug/common/debug';
|
import { IDebugService, State, IBreakpoint } from 'vs/workbench/contrib/debug/common/debug';
|
||||||
import { Thread } from 'vs/workbench/contrib/debug/common/debugModel';
|
import { Thread } from 'vs/workbench/contrib/debug/common/debugModel';
|
||||||
|
import { getNotebookEditorFromEditorPane } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||||
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
|
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
|
||||||
import { CellEditType, CellUri, NotebookCellsChangeType } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
import { CellEditType, CellUri, NotebookCellsChangeType } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||||
import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
|
import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
|
||||||
|
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||||
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
|
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
|
||||||
|
|
||||||
class NotebookBreakpoints extends Disposable implements IWorkbenchContribution {
|
class NotebookBreakpoints extends Disposable implements IWorkbenchContribution {
|
||||||
constructor(
|
constructor(
|
||||||
@IDebugService private readonly _debugService: IDebugService,
|
@IDebugService private readonly _debugService: IDebugService,
|
||||||
@INotebookService _notebookService: INotebookService,
|
@INotebookService _notebookService: INotebookService,
|
||||||
|
@IEditorService private readonly _editorService: IEditorService,
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -55,6 +59,29 @@ class NotebookBreakpoints extends Disposable implements IWorkbenchContribution {
|
||||||
this.updateBreakpoints(model);
|
this.updateBreakpoints(model);
|
||||||
listeners.get(model.uri)?.dispose();
|
listeners.get(model.uri)?.dispose();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
this._register(this._debugService.getModel().onDidChangeBreakpoints(e => {
|
||||||
|
const newCellBp = e?.added?.find(bp => 'uri' in bp && bp.uri.scheme === Schemas.vscodeNotebookCell) as IBreakpoint | undefined;
|
||||||
|
if (newCellBp) {
|
||||||
|
const parsed = CellUri.parse(newCellBp.uri);
|
||||||
|
if (!parsed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const editor = getNotebookEditorFromEditorPane(this._editorService.activeEditorPane);
|
||||||
|
if (!editor || !editor.hasModel() || editor.viewModel.uri.toString() !== parsed.notebook.toString()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const cell = editor.viewModel.getCellByHandle(parsed.handle);
|
||||||
|
if (!cell) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
editor.focusElement(cell);
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateBreakpoints(model: NotebookTextModel): void {
|
private updateBreakpoints(model: NotebookTextModel): void {
|
||||||
|
|
Loading…
Reference in a new issue