@@ -116,6 +116,7 @@ export class SimpleFileDialog {
116
116
private autoCompletePathSegment : string = '' ;
117
117
private activeItem : FileQuickPickItem | undefined ;
118
118
private userHome ! : URI ;
119
+ private isWindows : boolean = false ;
119
120
private badPath : string | undefined ;
120
121
private remoteAgentEnvironment : IRemoteAgentEnvironment | null | undefined ;
121
122
private separator : string = '/' ;
@@ -251,6 +252,7 @@ export class SimpleFileDialog {
251
252
this . allowFileSelection = ! ! this . options . canSelectFiles ;
252
253
this . separator = this . labelService . getSeparator ( this . scheme , this . remoteAuthority ) ;
253
254
this . hidden = false ;
255
+ this . isWindows = await this . checkIsWindowsOS ( ) ;
254
256
let homedir : URI = this . options . defaultUri ? this . options . defaultUri : this . workspaceContextService . getWorkspace ( ) . folders [ 0 ] . uri ;
255
257
let stat : IFileStat | undefined ;
256
258
let ext : string = resources . extname ( homedir ) ;
@@ -780,7 +782,7 @@ export class SimpleFileDialog {
780
782
// Show a yes/no prompt
781
783
const message = nls . localize ( 'remoteFileDialog.validateExisting' , '{0} already exists. Are you sure you want to overwrite it?' , resources . basename ( uri ) ) ;
782
784
return this . yesNoPrompt ( uri , message ) ;
783
- } else if ( ! ( isValidBasename ( resources . basename ( uri ) , await this . isWindowsOS ( ) ) ) ) {
785
+ } else if ( ! ( isValidBasename ( resources . basename ( uri ) , this . isWindows ) ) ) {
784
786
// Filename not allowed
785
787
this . filePickBox . validationMessage = nls . localize ( 'remoteFileDialog.validateBadFilename' , 'Please enter a valid file name.' ) ;
786
788
return Promise . resolve ( false ) ;
@@ -794,7 +796,7 @@ export class SimpleFileDialog {
794
796
// File or folder doesn't exist
795
797
this . filePickBox . validationMessage = nls . localize ( 'remoteFileDialog.validateNonexistentDir' , 'Please enter a path that exists.' ) ;
796
798
return Promise . resolve ( false ) ;
797
- } else if ( uri . path === '/' && ( await this . isWindowsOS ( ) ) ) {
799
+ } else if ( uri . path === '/' && this . isWindows ) {
798
800
this . filePickBox . validationMessage = nls . localize ( 'remoteFileDialog.windowsDriveLetter' , 'Please start the path with a drive letter.' ) ;
799
801
return Promise . resolve ( false ) ;
800
802
} else if ( stat . isDirectory && ! this . allowFolderSelection ) {
@@ -871,7 +873,7 @@ export class SimpleFileDialog {
871
873
}
872
874
873
875
private pathFromUri ( uri : URI , endWithSeparator : boolean = false ) : string {
874
- let result : string = normalizeDriveLetter ( uri . fsPath ) . replace ( / \n / g, '' ) ;
876
+ let result : string = normalizeDriveLetter ( uri . fsPath , this . isWindows ) . replace ( / \n / g, '' ) ;
875
877
if ( this . separator === '/' ) {
876
878
result = result . replace ( / \\ / g, this . separator ) ;
877
879
} else {
@@ -892,7 +894,7 @@ export class SimpleFileDialog {
892
894
}
893
895
}
894
896
895
- private async isWindowsOS ( ) : Promise < boolean > {
897
+ private async checkIsWindowsOS ( ) : Promise < boolean > {
896
898
let isWindowsOS = isWindows ;
897
899
const env = await this . getRemoteAgentEnvironment ( ) ;
898
900
if ( env ) {
0 commit comments