File tree 1 file changed +26
-0
lines changed
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -207,6 +207,32 @@ export class DirTreeListing extends DirListing {
207
207
return this . _model ;
208
208
}
209
209
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
+ const 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
+ const item : Contents . IModel = items [ index ] ;
224
+ if ( item . type === 'directory' && this . model . path === '/' + item . path ) {
225
+ this . model . path = '/' + PathExt . dirname ( item . path ) ;
226
+ }
227
+
228
+ const rename = super . rename ( ) ;
229
+
230
+ // Revert path change
231
+ this . model . path = oldModelPath ;
232
+
233
+ return rename ;
234
+ }
235
+
210
236
private async _eventDblClick ( event : MouseEvent ) : Promise < void > {
211
237
const entry = this . modelForClick ( event ) ;
212
238
You can’t perform that action at this time.
0 commit comments