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
145145 return ;
146146 }
147147
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 ! ) ) {
150149 return ;
151150 }
152151
@@ -313,6 +312,25 @@ export class DragAndDropController implements TreeDragAndDropController<Explorer
313312 return false ;
314313 }
315314
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+
316334 /**
317335 * Trigger a workspace edit that move the source node into the target node.
318336 */
You can’t perform that action at this time.
0 commit comments