@@ -35,7 +35,7 @@ import { coalesce } from 'vs/base/common/arrays';
35
35
import { suggestFilename } from 'vs/base/common/mime' ;
36
36
import { INotificationService } from 'vs/platform/notification/common/notification' ;
37
37
import { toErrorMessage } from 'vs/base/common/errorMessage' ;
38
- import { resolve } from 'vs/base/common /path' ;
38
+ import { IRemotePathService } from 'vs/workbench/services /path/common/remotePathService ' ;
39
39
40
40
/**
41
41
* The workbench file service implementation implements the raw file service spec and adds additional methods on top.
@@ -85,7 +85,8 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
85
85
@IFilesConfigurationService protected readonly filesConfigurationService : IFilesConfigurationService ,
86
86
@ITextModelService private readonly textModelService : ITextModelService ,
87
87
@ICodeEditorService private readonly codeEditorService : ICodeEditorService ,
88
- @INotificationService private readonly notificationService : INotificationService
88
+ @INotificationService private readonly notificationService : INotificationService ,
89
+ @IRemotePathService private readonly remotePathService : IRemotePathService
89
90
) {
90
91
super ( ) ;
91
92
@@ -321,12 +322,12 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
321
322
322
323
// Untitled with associated file path don't need to prompt
323
324
if ( model . hasAssociatedFilePath ) {
324
- targetUri = this . suggestSavePath ( resource ) ;
325
+ targetUri = await this . suggestSavePath ( resource ) ;
325
326
}
326
327
327
328
// Otherwise ask user
328
329
else {
329
- targetUri = await this . fileDialogService . pickFileToSave ( this . suggestSavePath ( resource ) , options ?. availableFileSystems ) ;
330
+ targetUri = await this . fileDialogService . pickFileToSave ( await this . suggestSavePath ( resource ) , options ?. availableFileSystems ) ;
330
331
}
331
332
332
333
// Save as if target provided
@@ -367,7 +368,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
367
368
368
369
// Get to target resource
369
370
if ( ! target ) {
370
- target = await this . fileDialogService . pickFileToSave ( this . suggestSavePath ( source ) , options ?. availableFileSystems ) ;
371
+ target = await this . fileDialogService . pickFileToSave ( await this . suggestSavePath ( source ) , options ?. availableFileSystems ) ;
371
372
}
372
373
373
374
if ( ! target ) {
@@ -546,7 +547,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
546
547
return ( await this . dialogService . confirm ( confirm ) ) . confirmed ;
547
548
}
548
549
549
- private suggestSavePath ( resource : URI ) : URI {
550
+ private async suggestSavePath ( resource : URI ) : Promise < URI > {
550
551
551
552
// Just take the resource as is if the file service can handle it
552
553
if ( this . fileService . canHandleResource ( resource ) ) {
@@ -582,16 +583,8 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
582
583
}
583
584
584
585
// Try to place where last active file was if any
585
- const defaultFilePath = this . fileDialogService . defaultFilePath ( ) ;
586
- if ( defaultFilePath ) {
587
- return joinPath ( defaultFilePath , suggestedFilename ) ;
588
- }
589
-
590
- // Finally fallback to suggest just the file name
591
- // Since we do not have a default file path to
592
- // put, we use path.resolve() to make sure the path
593
- // is absolute.
594
- return toLocalResource ( resource . with ( { path : resolve ( suggestedFilename ) } ) , remoteAuthority ) ;
586
+ // Otherwise fallback to user home
587
+ return joinPath ( this . fileDialogService . defaultFilePath ( ) || ( await this . remotePathService . userHome ) , suggestedFilename ) ;
595
588
}
596
589
597
590
//#endregion
0 commit comments