File tree Expand file tree Collapse file tree 3 files changed +48
-9
lines changed
packages/app/src/app/overmind Expand file tree Collapse file tree 3 files changed +48
-9
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,27 @@ export class ModelsHandler {
112112 return moduleModel . model ;
113113 } ;
114114
115+ public async updateTabsPath ( oldPath : string , newPath : string ) {
116+ const oldModelPath = '/sandbox' + oldPath ;
117+ const newModelPath = '/sandbox' + newPath ;
118+
119+ return Promise . all (
120+ Object . keys ( this . moduleModels ) . map ( async path => {
121+ if ( oldModelPath === path ) {
122+ const model = await this . moduleModels [ path ] . model ;
123+
124+ // This runs remove/add automatically
125+ return this . editorApi . textFileService . move (
126+ model . uri ,
127+ this . monaco . Uri . file ( newModelPath )
128+ ) ;
129+ }
130+
131+ return Promise . resolve ( ) ;
132+ } )
133+ ) ;
134+ }
135+
115136 public async applyOperation ( moduleShortid : string , operation : any ) {
116137 const module = this . sandbox . modules . find ( m => m . shortid === moduleShortid ) ;
117138
Original file line number Diff line number Diff line change @@ -267,15 +267,21 @@ export class VSCodeEffect {
267267 if ( this . editorApi ) {
268268 const groupsToClose = this . editorApi . editorService . editorGroupService . getGroups ( ) ;
269269
270- await Promise . all ( [
271- ...groupsToClose . map ( group => group . closeAllEditors ( ) ) ,
272- ...groupsToClose . map ( group =>
273- this . editorApi . editorService . editorGroupService . removeGroup ( group )
274- ) ,
275- ] ) ;
270+ await Promise . all (
271+ groupsToClose . map ( group =>
272+ Promise . all ( [
273+ group . closeAllEditors ( ) ,
274+ this . editorApi . editorService . editorGroupService . removeGroup ( group ) ,
275+ ] )
276+ )
277+ ) ;
276278 }
277279 }
278280
281+ public async updateTabsPath ( oldPath : string , newPath : string ) {
282+ return this . modelsHandler . updateTabsPath ( oldPath , newPath ) ;
283+ }
284+
279285 public async openModule ( module : Module ) {
280286 await this . initialized ;
281287
@@ -402,9 +408,9 @@ export class VSCodeEffect {
402408 private async enableExtension ( id : string ) {
403409 const extensionEnablementService = await this . extensionEnablementService
404410 . promise ;
405- const extensionIdentifier = ( await extensionEnablementService . getDisabledExtensions ( ) ) . find (
406- ext => ext . id === id
407- ) ;
411+ const extensionIdentifier = (
412+ await extensionEnablementService . getDisabledExtensions ( )
413+ ) . find ( ext => ext . id === id ) ;
408414
409415 if ( extensionIdentifier ) {
410416 // Sadly we have to call a private api for this. Might change this once we have extension management
Original file line number Diff line number Diff line change @@ -44,6 +44,13 @@ export const moduleRenamed: AsyncAction<{
4444 ) ;
4545
4646 effects . vscode . fs . rename ( state . editor . modulesByPath , oldPath , module . path ) ;
47+
48+ await effects . vscode . updateTabsPath ( oldPath , module . path ) ;
49+
50+ if ( state . editor . currentModuleShortid === module . shortid ) {
51+ effects . vscode . openModule ( module ) ;
52+ }
53+
4754 actions . editor . internal . updatePreviewCode ( ) ;
4855 try {
4956 await effects . api . saveModuleTitle ( sandbox . id , moduleShortid , title ) ;
@@ -54,6 +61,11 @@ export const moduleRenamed: AsyncAction<{
5461 } catch ( error ) {
5562 module . title = oldTitle ;
5663 state . editor . modulesByPath = effects . vscode . fs . create ( sandbox ) ;
64+
65+ if ( state . editor . currentModuleShortid === module . shortid ) {
66+ effects . vscode . openModule ( module ) ;
67+ }
68+
5769 actions . editor . internal . updatePreviewCode ( ) ;
5870 effects . notificationToast . error ( 'Could not rename file' ) ;
5971 }
You can’t perform that action at this time.
0 commit comments