99 JupyterFrontEnd ,
1010 JupyterFrontEndPlugin ,
1111 JupyterLab ,
12- LayoutRestorer ,
1312} from '@jupyterlab/application' ;
1413
1514import {
@@ -20,7 +19,6 @@ import {
2019 IToolbarWidgetRegistry ,
2120 IWindowResolver ,
2221 showErrorMessage ,
23- WindowResolver ,
2422} from '@jupyterlab/apputils' ;
2523
2624import { ConsolePanel } from '@jupyterlab/console' ;
@@ -57,8 +55,11 @@ import {
5755 SidePanelPalette ,
5856 INotebookPathOpener ,
5957 defaultNotebookPathOpener ,
58+ NotebookLayoutRestorer ,
6059} from '@jupyter-notebook/application' ;
6160
61+ import { NotebookTreeWidget } from '@jupyter-notebook/tree' ;
62+
6263import { jupyterIcon } from '@jupyter-notebook/ui-components' ;
6364
6465import { PromiseDelegate } from '@lumino/coreutils' ;
@@ -196,23 +197,32 @@ const layoutRestorer: JupyterFrontEndPlugin<ILayoutRestorer | null> = {
196197 notebookShell : INotebookShell | null
197198 ) => {
198199 if ( ! notebookShell ) {
199- console . log ( 'No layout for this view' ) ;
200200 return null ;
201201 }
202-
203202 const first = app . started ;
204203 const registry = app . commands ;
205204
206- const restorer = new LayoutRestorer ( {
205+ const restorer = new NotebookLayoutRestorer ( {
207206 connector : state ,
208207 first,
209208 registry,
210209 } ) ;
211210
212- // Restore the layout.
213- void notebookShell . restoreLayout ( restorer , { } ) . then ( ( ) => {
214- notebookShell . layoutModified . connect ( ( ) => {
215- void restorer . save ( notebookShell . saveLayout ( ) ) ;
211+ // Restore the layout when the main widget is loaded.
212+ void notebookShell . mainWidgetLoaded . then ( ( ) => {
213+ // Whether to actually restore the layout or not (not for the tree view).
214+ const restoreLayout = ! (
215+ notebookShell . currentWidget instanceof NotebookTreeWidget
216+ ) ;
217+
218+ // Call the restorer even if the layout must not be restored, to resolve the
219+ // promise.
220+ void notebookShell . restoreLayout ( restorer , restoreLayout ) . then ( ( ) => {
221+ if ( restoreLayout ) {
222+ notebookShell . layoutModified . connect ( ( ) => {
223+ void restorer . save ( notebookShell . saveLayout ( ) ) ;
224+ } ) ;
225+ }
216226 } ) ;
217227 } ) ;
218228
@@ -519,15 +529,10 @@ const resolver: JupyterFrontEndPlugin<IWindowResolver> = {
519529 description : 'Provides the window name resolver.' ,
520530 autoStart : true ,
521531 provides : IWindowResolver ,
522- requires : [ JupyterFrontEnd . IPaths , IRouter ] ,
523- activate : async (
524- app : JupyterFrontEnd ,
525- paths : JupyterFrontEnd . IPaths ,
526- router : IRouter
527- ) => {
528- const solver = new WindowResolver ( ) ;
529- ( solver as any ) . _name = 'nb-default' ;
530- return solver ;
532+ activate : async ( app : JupyterFrontEnd ) => {
533+ return {
534+ name : 'nb-default' ,
535+ } ;
531536 } ,
532537} ;
533538
0 commit comments