Do not close an already opened console if the command come from a menu

pull/7790/head
Nicolas Brichet 4 months ago
parent f0d27c0fa2
commit aa4c66bfaa

@ -13,7 +13,10 @@
"items": [
{
"command": "scratch-pad-console:open",
"rank": 2
"rank": 2,
"args": {
"isMenu": true
}
}
]
}

@ -179,17 +179,19 @@ const scratchPadConsole: JupyterFrontEndPlugin<void> = {
: trans.__('Scratch-pad console'),
isVisible: () => !!tracker.currentWidget,
icon: (args) => (args['isPalette'] ? undefined : consoleIcon),
execute: async () => {
execute: async (args) => {
if (!notebookShell) {
return;
}
const consoleId = scratchPadConsole.id;
const sidebar = notebookShell.rightHandler;
// Close the console if it is already opened.
// Close the console if it is already opened (shortcut only).
if (sidebar.isVisible && sidebar.currentWidget?.id === consoleId) {
notebookShell.collapseRight();
notebookShell.currentWidget?.activate();
if (!args.isPalette && !args.isMenu) {
notebookShell.collapseRight();
notebookShell.currentWidget?.activate();
}
return;
}
@ -235,6 +237,12 @@ const scratchPadConsole: JupyterFrontEndPlugin<void> = {
trans.__('Whether the command is executed from the palette')
),
},
isMenu: {
type: 'boolean',
description: trans.__(
trans.__('Whether the command is executed from the menu')
),
},
},
},
},

Loading…
Cancel
Save