@@ -55,6 +55,11 @@ const EDITOR_FACTORY = 'Editor';
55
55
*/
56
56
const TREE_PATTERN = new RegExp ( '/(notebooks|edit)/(.*)' ) ;
57
57
58
+ /**
59
+ * A regular expression to suppress the file extension from display for .ipynb files.
60
+ */
61
+ const STRIP_IPYNB = / \. i p y n b $ / ;
62
+
58
63
/**
59
64
* The command IDs used by the application plugin.
60
65
*/
@@ -383,15 +388,16 @@ const tabTitle: JupyterFrontEndPlugin<void> = {
383
388
const title =
384
389
current . sessionContext . path || current . sessionContext . name ;
385
390
const basename = PathExt . basename ( title ) ;
386
- document . title = basename ;
391
+ // Strip the ".ipynb" suffix from filenames for display in tab titles.
392
+ document . title = basename . replace ( STRIP_IPYNB , '' ) ;
387
393
} ;
388
394
current . sessionContext . sessionChanged . connect ( update ) ;
389
395
update ( ) ;
390
396
return ;
391
397
} else if ( current instanceof DocumentWidget ) {
392
398
const update = ( ) => {
393
399
const basename = PathExt . basename ( current . context . path ) ;
394
- document . title = basename ;
400
+ document . title = basename . replace ( STRIP_IPYNB , '' ) ;
395
401
} ;
396
402
current . context . pathChanged . connect ( update ) ;
397
403
update ( ) ;
@@ -434,11 +440,8 @@ const title: JupyterFrontEndPlugin<void> = {
434
440
return ;
435
441
}
436
442
437
- // Don't show the file extension for .ipynb files.
438
- const stripIpynb = / \. i p y n b $ / ;
439
-
440
443
const h = document . createElement ( 'h1' ) ;
441
- h . textContent = current . title . label . replace ( stripIpynb , '' ) ;
444
+ h . textContent = current . title . label . replace ( STRIP_IPYNB , '' ) ;
442
445
widget . node . appendChild ( h ) ;
443
446
widget . node . style . marginLeft = '10px' ;
444
447
if ( ! docManager ) {
@@ -472,7 +475,7 @@ const title: JupyterFrontEndPlugin<void> = {
472
475
const newPath = current . context . path ?? result . path ;
473
476
const basename = PathExt . basename ( newPath ) ;
474
477
475
- h . textContent = basename . replace ( stripIpynb , '' ) ;
478
+ h . textContent = basename . replace ( STRIP_IPYNB , '' ) ;
476
479
if ( ! router ) {
477
480
return ;
478
481
}
0 commit comments