mirror of
https://github.com/jupyter/notebook.git
synced 2025-03-01 12:56:54 +08:00
Show path in the console tab title
This commit is contained in:
parent
9029689ed0
commit
18106a006b
@ -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…
Reference in New Issue
Block a user