Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collapse debugger panel when disabling debugger #13088

Merged
merged 5 commits into from Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/debugger-extension/schema/main.json
Expand Up @@ -106,6 +106,12 @@
"description": "A regular expression filter to apply by default when showing the kernel sources",
"type": "string",
"default": ""
},
"autoCollapseDebuggerSidebar": {
"title": "Auto Collapse Debugger Sidebar",
"description": "Collapse the debugger sidebar when disabling the debugger on a document.",
"type": "boolean",
"default": false
}
},
"additionalProperties": false,
Expand Down
25 changes: 23 additions & 2 deletions packages/debugger-extension/src/index.ts
Expand Up @@ -559,7 +559,8 @@ const main: JupyterFrontEndPlugin<void> = {
IDebuggerSources,
ILabShell,
ILayoutRestorer,
ILoggerRegistry
ILoggerRegistry,
ISettingRegistry
],
autoStart: true,
activate: async (
Expand All @@ -572,7 +573,8 @@ const main: JupyterFrontEndPlugin<void> = {
debuggerSources: IDebugger.ISources | null,
labShell: ILabShell | null,
restorer: ILayoutRestorer | null,
loggerRegistry: ILoggerRegistry | null
loggerRegistry: ILoggerRegistry | null,
settingRegistry: ISettingRegistry | null
): Promise<void> => {
const trans = translator.load('jupyterlab');
const { commands, shell, serviceManager } = app;
Expand Down Expand Up @@ -722,10 +724,29 @@ const main: JupyterFrontEndPlugin<void> = {
}
});

let autoCollapseSidebar = false;

if (settingRegistry) {
const setting = await settingRegistry.load(main.id);
const updateSettings = (): void => {
autoCollapseSidebar = setting.get('autoCollapseDebuggerSidebar')
.composite as boolean;
};
updateSettings();
setting.changed.connect(updateSettings);
}

service.eventMessage.connect((_, event): void => {
commands.notifyCommandChanged();
if (labShell && event.event === 'initialized') {
labShell.activateById(sidebar.id);
} else if (
labShell &&
sidebar.isVisible &&
event.event === 'terminated' &&
autoCollapseSidebar
) {
labShell.collapseRight();
}
});

Expand Down