Show path in the console tab title

This commit is contained in:
Jeremy Tuloup 2021-09-07 16:23:49 +02:00
parent 9029689ed0
commit 18106a006b
2 changed files with 19 additions and 7 deletions

View File

@ -44,6 +44,7 @@
"@jupyterlab/celltags": "^3.1.8",
"@jupyterlab/codeeditor": "^3.1.8",
"@jupyterlab/codemirror": "^3.1.8",
"@jupyterlab/console": "^3.1.8",
"@jupyterlab/coreutils": "^5.1.8",
"@jupyterlab/docmanager": "^3.1.8",
"@jupyterlab/docregistry": "^3.1.8",

View File

@ -17,6 +17,8 @@ import {
ICommandPalette
} from '@jupyterlab/apputils';
import { ConsolePanel } from '@jupyterlab/console';
import { PageConfig, PathExt, URLExt } from '@jupyterlab/coreutils';
import { IDocumentManager, renameDialog } from '@jupyterlab/docmanager';
@ -347,15 +349,24 @@ const tabTitle: JupyterFrontEndPlugin<void> = {
activate: (app: JupyterFrontEnd, shell: IRetroShell) => {
const setTabTitle = () => {
const current = shell.currentWidget;
if (!(current instanceof DocumentWidget)) {
if (current instanceof ConsolePanel) {
const update = () => {
const title =
current.sessionContext.path || current.sessionContext.name;
const basename = PathExt.basename(title);
document.title = basename;
};
current.sessionContext.sessionChanged.connect(update);
update();
return;
} else if (current instanceof DocumentWidget) {
const update = () => {
const basename = PathExt.basename(current.context.path);
document.title = basename;
};
current.context.pathChanged.connect(update);
update();
}
const update = () => {
const basename = PathExt.basename(current.context.path);
document.title = basename;
};
current.context.pathChanged.connect(update);
update();
};
shell.currentChanged.connect(setTabTitle);