Merge pull request #208 from jtpio/console-title

Show path in the console tab title
pull/6294/head
Jeremy Tuloup 5 years ago committed by GitHub
commit 9e534b81be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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",

@ -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);

Loading…
Cancel
Save