@@ -20,7 +20,9 @@ import { editor as monacoEditor, Uri } from 'mo/monaco';
20
20
21
21
import {
22
22
EditorService ,
23
+ ExplorerService ,
23
24
IEditorService ,
25
+ IExplorerService ,
24
26
IStatusBarService ,
25
27
StatusBarService ,
26
28
} from 'mo/services' ;
@@ -56,11 +58,13 @@ export class EditorController extends Controller implements IEditorController {
56
58
private editorStates = new Map ( ) ;
57
59
private readonly editorService : IEditorService ;
58
60
private readonly statusBarService : IStatusBarService ;
61
+ private readonly explorerService : IExplorerService ;
59
62
60
63
constructor ( ) {
61
64
super ( ) ;
62
65
this . editorService = container . resolve ( EditorService ) ;
63
66
this . statusBarService = container . resolve ( StatusBarService ) ;
67
+ this . explorerService = container . resolve ( ExplorerService ) ;
64
68
}
65
69
66
70
public open < T > ( tab : IEditorTab < any > , groupId ?: number ) {
@@ -107,21 +111,24 @@ export class EditorController extends Controller implements IEditorController {
107
111
108
112
public updateCurrentValue = ( ) => {
109
113
const { current } = this . editorService . getState ( ) ;
110
- const model = current ?. editorInstance ?. getModel ( ) ;
111
- const newValue = model . getValue ( ) ;
112
- current ?. editorInstance ?. executeEdits ( 'update-value' , [
113
- {
114
- range : model . getFullModelRange ( ) ,
115
- text : newValue ,
116
- forceMoveMarkers : true ,
117
- } ,
118
- ] ) ;
119
- current ?. editorInstance ?. focus ( ) ;
114
+ if ( current ) {
115
+ const model = current ?. editorInstance ?. getModel ( ) ;
116
+ const newValue = model . getValue ( ) ;
117
+ current ?. editorInstance ?. executeEdits ( 'update-value' , [
118
+ {
119
+ range : model . getFullModelRange ( ) ,
120
+ text : newValue ,
121
+ forceMoveMarkers : true ,
122
+ } ,
123
+ ] ) ;
124
+ current ?. editorInstance ?. focus ( ) ;
125
+ }
120
126
} ;
121
127
122
128
public onCloseTab = ( tabId ?: string , groupId ?: number ) => {
123
129
if ( tabId && groupId ) {
124
130
this . editorService . closeTab ( tabId , groupId ) ;
131
+ this . explorerService . forceUpdate ( ) ;
125
132
this . updateCurrentValue ( ) ;
126
133
this . emit ( EditorEvent . OnCloseTab , tabId , groupId ) ;
127
134
}
0 commit comments