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 1 commit
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 debugger sidebar when disabling debugger",
"type": "boolean",
"default": false
yanmulin marked this conversation as resolved.
Show resolved Hide resolved
}
},
"additionalProperties": false,
Expand Down
21 changes: 18 additions & 3 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,14 +724,27 @@ const main: JupyterFrontEndPlugin<void> = {
}
});

let autoCollapseSidebar = false;

if (settingRegistry) {
const setting = await settingRegistry.load(main.id);
const updateSettings = (): void => {
autoCollapseSidebar = setting.get('AutoCollapseDebuggerSidebar')
yanmulin marked this conversation as resolved.
Show resolved Hide resolved
.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'
event.event === 'terminated' &&
autoCollapseSidebar
) {
labShell.collapseRight();
}
Expand Down