@@ -17,7 +17,7 @@ export interface IEditorWindow extends Omit<IPublicModelWindow<IResource>, 'chan
1717
1818 editorViews : Map < string , IViewContext > ;
1919
20- editorView : IViewContext ;
20+ _editorView : IViewContext ;
2121
2222 changeViewName : ( name : string , ignoreEmit ?: boolean ) => void ;
2323
@@ -54,14 +54,21 @@ export class EditorWindow implements IEditorWindow {
5454
5555 url : string | undefined ;
5656
57- @obx . ref editorView : Context ;
57+ @obx . ref _editorView : Context ;
5858
5959 @obx editorViews : Map < string , Context > = new Map < string , Context > ( ) ;
6060
6161 @obx initReady = false ;
6262
6363 sleep : boolean | undefined ;
6464
65+ get editorView ( ) {
66+ if ( ! this . _editorView ) {
67+ return this . editorViews . values ( ) . next ( ) . value ;
68+ }
69+ return this . _editorView ;
70+ }
71+
6572 constructor ( readonly resource : IResource , readonly workspace : IWorkspace , private config : IWindowCOnfig ) {
6673 makeObservable ( this ) ;
6774 this . title = config . title ;
@@ -75,10 +82,10 @@ export class EditorWindow implements IEditorWindow {
7582 updateState ( state : WINDOW_STATE ) : void {
7683 switch ( state ) {
7784 case WINDOW_STATE . active :
78- this . editorView ?. setActivate ( true ) ;
85+ this . _editorView ?. setActivate ( true ) ;
7986 break ;
8087 case WINDOW_STATE . inactive :
81- this . editorView ?. setActivate ( false ) ;
88+ this . _editorView ?. setActivate ( false ) ;
8289 break ;
8390 case WINDOW_STATE . destroyed :
8491 break ;
@@ -146,7 +153,7 @@ export class EditorWindow implements IEditorWindow {
146153 for ( let i = 0 ; i < editorViews . length ; i ++ ) {
147154 const name = editorViews [ i ] . viewName ;
148155 await this . initViewType ( name ) ;
149- if ( ! this . editorView ) {
156+ if ( ! this . _editorView ) {
150157 this . changeViewName ( name ) ;
151158 }
152159 }
@@ -190,14 +197,14 @@ export class EditorWindow implements IEditorWindow {
190197 } ;
191198
192199 changeViewName = ( name : string , ignoreEmit : boolean = true ) => {
193- this . editorView ?. setActivate ( false ) ;
194- this . editorView = this . editorViews . get ( name ) ! ;
200+ this . _editorView ?. setActivate ( false ) ;
201+ this . _editorView = this . editorViews . get ( name ) ! ;
195202
196- if ( ! this . editorView ) {
203+ if ( ! this . _editorView ) {
197204 return ;
198205 }
199206
200- this . editorView . setActivate ( true ) ;
207+ this . _editorView . setActivate ( true ) ;
201208
202209 if ( ! ignoreEmit ) {
203210 this . emitter . emit ( 'window.change.view.type' , name ) ;
0 commit comments