File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -145,8 +145,7 @@ export class DragAndDropController implements TreeDragAndDropController<Explorer
145
145
return ;
146
146
}
147
147
148
- // check if the target node is source node itself or its parent.
149
- if ( target ?. isItselfOrAncestorOf ( source , 1 /*levelToCheck*/ ) ) {
148
+ if ( this . isTheSameOrParent ( target ! , source ! ) ) {
150
149
return ;
151
150
}
152
151
@@ -313,6 +312,25 @@ export class DragAndDropController implements TreeDragAndDropController<Explorer
313
312
return false ;
314
313
}
315
314
315
+ /**
316
+ * Check whether the target node is the same or parent of the source node.
317
+ * If the target node's file path is parent of the source node's, `true`
318
+ * well be returned as well.
319
+ */
320
+ private isTheSameOrParent ( target : ExplorerNode , source : DataNode ) : boolean {
321
+ if ( target . isItselfOrAncestorOf ( source , 1 /*levelToCheck*/ ) ) {
322
+ return true ;
323
+ }
324
+
325
+ if ( ( target instanceof DataNode ) && target . uri && source . uri ) {
326
+ const targetPath = Uri . parse ( target . uri ) . fsPath ;
327
+ const sourcePath = Uri . parse ( source . uri ) . fsPath ;
328
+ return path . relative ( sourcePath , targetPath ) === ".." ;
329
+ }
330
+
331
+ return false ;
332
+ }
333
+
316
334
/**
317
335
* Trigger a workspace edit that move the source node into the target node.
318
336
*/
You can’t perform that action at this time.
0 commit comments