File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -207,6 +207,34 @@ export class DirTreeListing extends DirListing {
207207 return this . _model ;
208208 }
209209
210+ rename ( ) : Promise < string > {
211+ // In the case of renaming directories, we need to fix the model path
212+ // So that it's the parent directory and not the directory itself
213+ //
214+ // We need to do this because we always change the model path upon directory
215+ // selection, unlike the
216+
217+ let oldModelPath = this . model . path ;
218+ // @ts -ignore
219+ const items = this . _sortedItems ;
220+ const path = Object . keys ( this . selection ) [ 0 ] ;
221+ // @ts -ignore
222+ const index = ArrayExt . findFirstIndex ( items , value => value . path === path ) ;
223+ // @ts -ignore
224+ const row = this . _items [ index ] ;
225+ const item : Contents . IModel = items [ index ] ;
226+ if ( item . type === 'directory' && this . model . path === '/' + item . path ) {
227+ this . model . path = '/' + PathExt . dirname ( item . path ) ;
228+ }
229+
230+ const rename = super . rename ( ) ;
231+
232+ // Revert path change
233+ this . model . path = oldModelPath ;
234+
235+ return rename ;
236+ }
237+
210238 private async _eventDblClick ( event : MouseEvent ) : Promise < void > {
211239 const entry = this . modelForClick ( event ) ;
212240
You can’t perform that action at this time.
0 commit comments