@@ -581,40 +581,46 @@ export class SimpleFileDialog implements ISimpleFileDialog {
581
581
valueUri = this . root ( this . currentFolder ) ;
582
582
value = this . pathFromUri ( valueUri ) ;
583
583
return await this . updateItems ( valueUri , true ) ? UpdateResult . UpdatedWithTrailing : UpdateResult . Updated ;
584
- } else if ( ! resources . extUriIgnorePathCase . isEqual ( this . currentFolder , valueUri ) && ( this . endsWithSlash ( value ) || ( ! resources . extUriIgnorePathCase . isEqual ( this . currentFolder , resources . dirname ( valueUri ) ) && resources . extUriIgnorePathCase . isEqualOrParent ( this . currentFolder , resources . dirname ( valueUri ) ) ) ) ) {
585
- let stat : IFileStatWithPartialMetadata | undefined ;
586
- try {
587
- stat = await this . fileService . stat ( valueUri ) ;
588
- } catch ( e ) {
589
- // do nothing
590
- }
591
- if ( stat && stat . isDirectory && ( resources . basename ( valueUri ) !== '.' ) && this . endsWithSlash ( value ) ) {
592
- valueUri = this . tryAddTrailingSeparatorToDirectory ( valueUri , stat ) ;
593
- return await this . updateItems ( valueUri ) ? UpdateResult . UpdatedWithTrailing : UpdateResult . Updated ;
594
- } else if ( this . endsWithSlash ( value ) ) {
595
- // The input box contains a path that doesn't exist on the system.
596
- this . filePickBox . validationMessage = nls . localize ( 'remoteFileDialog.badPath' , 'The path does not exist.' ) ;
597
- // Save this bad path. It can take too long to a stat on every user entered character, but once a user enters a bad path they are likely
598
- // to keep typing more bad path. We can compare against this bad path and see if the user entered path starts with it.
599
- this . badPath = value ;
600
- return UpdateResult . InvalidPath ;
601
- } else {
602
- let inputUriDirname = resources . dirname ( valueUri ) ;
603
- const currentFolderWithoutSep = resources . removeTrailingPathSeparator ( resources . addTrailingPathSeparator ( this . currentFolder ) ) ;
604
- const inputUriDirnameWithoutSep = resources . removeTrailingPathSeparator ( resources . addTrailingPathSeparator ( inputUriDirname ) ) ;
605
- if ( ! resources . extUriIgnorePathCase . isEqual ( currentFolderWithoutSep , inputUriDirnameWithoutSep )
606
- && ( ! / ^ [ a - z A - Z ] : $ / . test ( this . filePickBox . value )
607
- || ! equalsIgnoreCase ( this . pathFromUri ( this . currentFolder ) . substring ( 0 , this . filePickBox . value . length ) , this . filePickBox . value ) ) ) {
608
- let statWithoutTrailing : IFileStatWithPartialMetadata | undefined ;
609
- try {
610
- statWithoutTrailing = await this . fileService . stat ( inputUriDirname ) ;
611
- } catch ( e ) {
612
- // do nothing
613
- }
614
- if ( statWithoutTrailing && statWithoutTrailing . isDirectory ) {
615
- this . badPath = undefined ;
616
- inputUriDirname = this . tryAddTrailingSeparatorToDirectory ( inputUriDirname , statWithoutTrailing ) ;
617
- return await this . updateItems ( inputUriDirname , false , resources . basename ( valueUri ) ) ? UpdateResult . UpdatedWithTrailing : UpdateResult . Updated ;
584
+ } else {
585
+ const newFolderIsOldFolder = resources . extUriIgnorePathCase . isEqual ( this . currentFolder , valueUri ) ;
586
+ const newFolderIsSubFolder = resources . extUriIgnorePathCase . isEqual ( this . currentFolder , resources . dirname ( valueUri ) ) ;
587
+ const newFolderIsParent = ! newFolderIsOldFolder && resources . extUriIgnorePathCase . isEqualOrParent ( this . currentFolder , resources . dirname ( valueUri ) ) ;
588
+ const newFolderIsUnrelated = ! newFolderIsOldFolder && ! newFolderIsParent && ! newFolderIsSubFolder ;
589
+ if ( this . endsWithSlash ( value ) || newFolderIsParent || newFolderIsUnrelated ) {
590
+ let stat : IFileStatWithPartialMetadata | undefined ;
591
+ try {
592
+ stat = await this . fileService . stat ( valueUri ) ;
593
+ } catch ( e ) {
594
+ // do nothing
595
+ }
596
+ if ( stat && stat . isDirectory && ( resources . basename ( valueUri ) !== '.' ) && this . endsWithSlash ( value ) ) {
597
+ valueUri = this . tryAddTrailingSeparatorToDirectory ( valueUri , stat ) ;
598
+ return await this . updateItems ( valueUri ) ? UpdateResult . UpdatedWithTrailing : UpdateResult . Updated ;
599
+ } else if ( this . endsWithSlash ( value ) ) {
600
+ // The input box contains a path that doesn't exist on the system.
601
+ this . filePickBox . validationMessage = nls . localize ( 'remoteFileDialog.badPath' , 'The path does not exist.' ) ;
602
+ // Save this bad path. It can take too long to a stat on every user entered character, but once a user enters a bad path they are likely
603
+ // to keep typing more bad path. We can compare against this bad path and see if the user entered path starts with it.
604
+ this . badPath = value ;
605
+ return UpdateResult . InvalidPath ;
606
+ } else {
607
+ let inputUriDirname = resources . dirname ( valueUri ) ;
608
+ const currentFolderWithoutSep = resources . removeTrailingPathSeparator ( resources . addTrailingPathSeparator ( this . currentFolder ) ) ;
609
+ const inputUriDirnameWithoutSep = resources . removeTrailingPathSeparator ( resources . addTrailingPathSeparator ( inputUriDirname ) ) ;
610
+ if ( ! resources . extUriIgnorePathCase . isEqual ( currentFolderWithoutSep , inputUriDirnameWithoutSep )
611
+ && ( ! / ^ [ a - z A - Z ] : $ / . test ( this . filePickBox . value )
612
+ || ! equalsIgnoreCase ( this . pathFromUri ( this . currentFolder ) . substring ( 0 , this . filePickBox . value . length ) , this . filePickBox . value ) ) ) {
613
+ let statWithoutTrailing : IFileStatWithPartialMetadata | undefined ;
614
+ try {
615
+ statWithoutTrailing = await this . fileService . stat ( inputUriDirname ) ;
616
+ } catch ( e ) {
617
+ // do nothing
618
+ }
619
+ if ( statWithoutTrailing && statWithoutTrailing . isDirectory ) {
620
+ this . badPath = undefined ;
621
+ inputUriDirname = this . tryAddTrailingSeparatorToDirectory ( inputUriDirname , statWithoutTrailing ) ;
622
+ return await this . updateItems ( inputUriDirname , false , resources . basename ( valueUri ) ) ? UpdateResult . UpdatedWithTrailing : UpdateResult . Updated ;
623
+ }
618
624
}
619
625
}
620
626
}
0 commit comments