|
@@ -68,6 +68,8 @@ export namespace CommandIDs {
|
|
|
export const mount = 'debugger:mount';
|
|
|
|
|
|
export const changeMode = 'debugger:change-mode';
|
|
|
+
|
|
|
+ export const closeDebugger = 'debugger:close';
|
|
|
}
|
|
|
|
|
|
async function setDebugSession(
|
|
@@ -104,6 +106,14 @@ class DebuggerHandler<H extends ConsoleHandler | NotebookHandler> {
|
|
|
handler.dispose();
|
|
|
delete this.handlers[widget.id];
|
|
|
});
|
|
|
+
|
|
|
+ debug.model.disposed.connect(async () => {
|
|
|
+ await debug.stop();
|
|
|
+ Object.keys(this.handlers).forEach(id => {
|
|
|
+ this.handlers[id].dispose();
|
|
|
+ });
|
|
|
+ this.handlers = {};
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -201,7 +211,7 @@ const notebooks: JupyterFrontEndPlugin<void> = {
|
|
|
) => {
|
|
|
const handler = new DebuggerHandler<NotebookHandler>(NotebookHandler);
|
|
|
|
|
|
- labShell.currentChanged.connect(async (_, update) => {
|
|
|
+ labShell.activeChanged.connect(async (_, update) => {
|
|
|
const widget = update.newValue;
|
|
|
if (!(widget instanceof NotebookPanel)) {
|
|
|
return;
|
|
@@ -217,7 +227,7 @@ const notebooks: JupyterFrontEndPlugin<void> = {
|
|
|
*/
|
|
|
const main: JupyterFrontEndPlugin<IDebugger> = {
|
|
|
id: '@jupyterlab/debugger:main',
|
|
|
- optional: [ILayoutRestorer, ICommandPalette],
|
|
|
+ optional: [ILayoutRestorer, ICommandPalette, ILabShell],
|
|
|
requires: [IStateDB, IEditorServices],
|
|
|
provides: IDebugger,
|
|
|
autoStart: true,
|
|
@@ -226,7 +236,8 @@ const main: JupyterFrontEndPlugin<IDebugger> = {
|
|
|
state: IStateDB,
|
|
|
editorServices: IEditorServices,
|
|
|
restorer: ILayoutRestorer | null,
|
|
|
- palette: ICommandPalette | null
|
|
|
+ palette: ICommandPalette | null,
|
|
|
+ labShell: ILabShell
|
|
|
): IDebugger => {
|
|
|
const { commands, shell } = app;
|
|
|
const editorFactory = editorServices.factoryService.newInlineEditor;
|
|
@@ -241,6 +252,22 @@ const main: JupyterFrontEndPlugin<IDebugger> = {
|
|
|
|
|
|
let widget: MainAreaWidget<Debugger>;
|
|
|
|
|
|
+ commands.addCommand(CommandIDs.closeDebugger, {
|
|
|
+ label: 'Close Debugger',
|
|
|
+ execute: args => {
|
|
|
+ if (!widget) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ widget.content.sidebar.close();
|
|
|
+ widget.dispose();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ app.contextMenu.addItem({
|
|
|
+ command: CommandIDs.closeDebugger,
|
|
|
+ selector: '.jp-DebuggerSidebar'
|
|
|
+ });
|
|
|
+
|
|
|
commands.addCommand(CommandIDs.mount, {
|
|
|
execute: async args => {
|
|
|
if (!widget) {
|
|
@@ -275,7 +302,11 @@ const main: JupyterFrontEndPlugin<IDebugger> = {
|
|
|
|
|
|
sidebar.id = 'jp-debugger-sidebar';
|
|
|
sidebar.title.label = 'Environment';
|
|
|
+
|
|
|
shell.add(sidebar, 'right', { activate: false });
|
|
|
+ if (labShell.currentWidget) {
|
|
|
+ labShell.currentWidget.activate();
|
|
|
+ }
|
|
|
|
|
|
if (restorer) {
|
|
|
restorer.add(sidebar, 'debugger-sidebar');
|