@@ -11,7 +11,8 @@ import {
1111 formatLocalize ,
1212 FileChangeType ,
1313 WithEventBus ,
14- OnEvent ,
14+ IDisposable ,
15+ IEventBus ,
1516} from '@ali/ide-core-common' ;
1617import {
1718 LaunchContribution ,
@@ -42,7 +43,6 @@ import { RefType } from './types';
4243
4344@Domain ( LaunchContribution , BrowserEditorContribution , CommandContribution )
4445export class CodeContribution
45- extends WithEventBus
4646 implements LaunchContribution , BrowserEditorContribution , CommandContribution {
4747 @Autowired ( )
4848 codeModel : CodeModelService ;
@@ -77,18 +77,19 @@ export class CodeContribution
7777 @Autowired ( IDiskFileProvider )
7878 diskFile : DiskFsProviderClient ;
7979
80+ @Autowired ( IEventBus )
81+ protected eventBus : IEventBus ;
82+
8083 private _unmount : ( ) => void | undefined ;
8184
8285 private _mounting = false ;
8386
87+ private _disposables : IDisposable [ ] = [ ] ;
88+
8489 async launch ( { rootFS } : IServerApp ) {
8590 const codeConfig = this . runtimeConfig ?. codeService ;
8691 if ( ! codeConfig ) return ;
8792
88- this . codeModel . onDidChangeRefPath ( ( path ) => {
89- console . log ( '>>>>>>>path' , path ) ;
90- } ) ;
91-
9293 let initDeferred : Deferred < void > | null = new Deferred ( ) ;
9394 this . codeModel . onDidChangeHEAD ( ( ) => {
9495 this . mountFilesystem ( rootFS ) . then ( ( ) => {
@@ -160,14 +161,22 @@ export class CodeContribution
160161 const { revealEntry } = this . codeModel ;
161162 if ( ! revealEntry ?. filepath ) return ;
162163 const uri = URI . file ( path . join ( this . appConfig . workspaceDir , revealEntry . filepath ) ) ;
164+ let wait : Promise < any > = Promise . resolve ( ) ;
163165 if ( revealEntry . type === 'blob' ) {
164- this . editorService . open ( uri , {
166+ wait = this . editorService . open ( uri , {
165167 preview : false ,
166168 deletedPolicy : 'fail' ,
167169 } ) ;
168170 } else if ( revealEntry . type === 'tree' ) {
169171 this . commandService . tryExecuteCommand ( FILE_COMMANDS . LOCATION . id , uri ) ;
170172 }
173+ wait . finally ( ( ) => {
174+ this . _disposables . push (
175+ this . eventBus . on ( EditorGroupChangeEvent , ( event ) => {
176+ this . onEditorGroupChangeEvent ( event ) ;
177+ } )
178+ ) ;
179+ } ) ;
171180 }
172181
173182 registerCommands ( commandRegistry : CommandRegistry ) {
@@ -209,7 +218,6 @@ export class CodeContribution
209218 ) ;
210219 }
211220
212- @OnEvent ( EditorGroupChangeEvent )
213221 onEditorGroupChangeEvent ( { payload : { newOpenType, newResource } } : EditorGroupChangeEvent ) {
214222 if ( newOpenType ?. type === 'code' && newResource && ! newResource . deleted ) {
215223 const fsPath = newResource . uri . codeUri . path ;
@@ -226,5 +234,6 @@ export class CodeContribution
226234
227235 dispose ( ) {
228236 this . _unmount ?.( ) ;
237+ this . _disposables . forEach ( ( disposer ) => disposer . dispose ( ) ) ;
229238 }
230239}
0 commit comments