@@ -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 ( ) ;
@@ -435,7 +441,7 @@ const title: JupyterFrontEndPlugin<void> = {
435
441
}
436
442
437
443
const h = document . createElement ( 'h1' ) ;
438
- h . textContent = current . title . label ;
444
+ h . textContent = current . title . label . replace ( STRIP_IPYNB , '' ) ;
439
445
widget . node . appendChild ( h ) ;
440
446
widget . node . style . marginLeft = '10px' ;
441
447
if ( ! docManager ) {
@@ -468,7 +474,8 @@ const title: JupyterFrontEndPlugin<void> = {
468
474
469
475
const newPath = current . context . path ?? result . path ;
470
476
const basename = PathExt . basename ( newPath ) ;
471
- h . textContent = basename ;
477
+
478
+ h . textContent = basename . replace ( STRIP_IPYNB , '' ) ;
472
479
if ( ! router ) {
473
480
return ;
474
481
}
0 commit comments