Skip to content
Open
7 changes: 7 additions & 0 deletions packages/application-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,18 @@ const opener: JupyterFrontEndPlugin<void> = {
): void => {
const { commands, docRegistry } = app;

const ignoreTreePattern = new RegExp('/tree/(.*)');
const command = 'router:tree';
commands.addCommand(command, {
execute: (args: any) => {
const parsed = args as IRouter.ILocation;
const matches = parsed.path.match(TREE_PATTERN) ?? [];
const isTreeMatch = parsed.path.match(ignoreTreePattern);

if (isTreeMatch) {
return;
}

const [, , path] = matches;
if (!path) {
return;
Expand Down
5 changes: 4 additions & 1 deletion packages/console-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ const opener: JupyterFrontEndPlugin<void> = {
activate: (app: JupyterFrontEnd, router: IRouter) => {
const { commands } = app;
const consolePattern = new RegExp('/consoles/(.*)');
const ignoreTreePattern = new RegExp('/(tree|notebooks|edit)/(.*)');

const command = 'router:console';
commands.addCommand(command, {
execute: (args: any) => {
const parsed = args as IRouter.ILocation;
const matches = parsed.path.match(consolePattern);
if (!matches) {
const isTreeMatch = parsed.path.match(ignoreTreePattern);

if (isTreeMatch || !matches) {
return;
}
const [, match] = matches;
Expand Down
5 changes: 4 additions & 1 deletion packages/terminal-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ const opener: JupyterFrontEndPlugin<void> = {
) => {
const { commands } = app;
const terminalPattern = new RegExp('/terminals/(.*)');
const ignoreTreePattern = new RegExp('/(tree|notebooks|edit)/(.*)');

const command = 'router:terminal';
commands.addCommand(command, {
execute: (args: any) => {
const parsed = args as IRouter.ILocation;
const matches = parsed.path.match(terminalPattern);
if (!matches) {
const isTreeMatch = parsed.path.match(ignoreTreePattern);

if (isTreeMatch || !matches) {
return;
}
const [, name] = matches;
Expand Down