diff --git a/src/vs/workbench/contrib/debug/browser/loadedScriptsView.ts b/src/vs/workbench/contrib/debug/browser/loadedScriptsView.ts index b090929fbd0..96bab8f09ee 100644 --- a/src/vs/workbench/contrib/debug/browser/loadedScriptsView.ts +++ b/src/vs/workbench/contrib/debug/browser/loadedScriptsView.ts @@ -348,7 +348,7 @@ class SessionTreeItem extends BaseTreeItem { // on unix try to tildify absolute paths path = normalize(path); if (!isWindows) { - path = tildify(path, (await this._pathService.userHome).fsPath); + path = tildify(path, (await this._pathService.userHome()).fsPath); } } } diff --git a/src/vs/workbench/contrib/externalTerminal/node/externalTerminal.contribution.ts b/src/vs/workbench/contrib/externalTerminal/node/externalTerminal.contribution.ts index c4b310c504a..84e406323be 100644 --- a/src/vs/workbench/contrib/externalTerminal/node/externalTerminal.contribution.ts +++ b/src/vs/workbench/contrib/externalTerminal/node/externalTerminal.contribution.ts @@ -40,7 +40,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ terminalService.openTerminal(paths.dirname(activeFile.fsPath)); } else { const pathService = accessor.get(IPathService); - const userHome = await pathService.userHome; + const userHome = await pathService.userHome(); terminalService.openTerminal(userHome.fsPath); } } diff --git a/src/vs/workbench/contrib/search/browser/anythingQuickAccess.ts b/src/vs/workbench/contrib/search/browser/anythingQuickAccess.ts index c386be60bba..a749425a97f 100644 --- a/src/vs/workbench/contrib/search/browser/anythingQuickAccess.ts +++ b/src/vs/workbench/contrib/search/browser/anythingQuickAccess.ts @@ -643,7 +643,7 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider { - return (await this.pathService.userHome) ?? URI.from({ scheme: this.scheme, authority: this.remoteAuthority, path: '/' }); + protected getUserHome(): Promise { + return this.pathService.userHome({ preferLocal: this.scheme === Schemas.file }); } private async pickResource(isSave: boolean = false): Promise { diff --git a/src/vs/workbench/services/path/common/pathService.ts b/src/vs/workbench/services/path/common/pathService.ts index d7518be3b41..c2e1b21bd5a 100644 --- a/src/vs/workbench/services/path/common/pathService.ts +++ b/src/vs/workbench/services/path/common/pathService.ts @@ -40,9 +40,10 @@ export interface IPathService { /** * Resolves the user-home directory for the target environment. * If the envrionment is connected to a remote, this will be the - * remote's user home directory, otherwise the local one. + * remote's user home directory, otherwise the local one unless + * `preferLocal` is set to `true`. */ - readonly userHome: Promise; + userHome(options?: { preferLocal: boolean }): Promise; /** * @deprecated use `userHome` instead. @@ -60,7 +61,7 @@ export abstract class AbstractPathService implements IPathService { private maybeUnresolvedUserHome: URI | undefined; constructor( - localUserHome: URI, + private localUserHome: URI, @IRemoteAgentService private readonly remoteAgentService: IRemoteAgentService ) { @@ -81,8 +82,8 @@ export abstract class AbstractPathService implements IPathService { })(); } - get userHome(): Promise { - return this.resolveUserHome; + async userHome(options?: { preferLocal: boolean }): Promise { + return options?.preferLocal ? this.localUserHome : this.resolveUserHome; } get resolvedUserHome(): URI | undefined { diff --git a/src/vs/workbench/services/textfile/browser/textFileService.ts b/src/vs/workbench/services/textfile/browser/textFileService.ts index fabf89c0b32..dcc69811e72 100644 --- a/src/vs/workbench/services/textfile/browser/textFileService.ts +++ b/src/vs/workbench/services/textfile/browser/textFileService.ts @@ -462,7 +462,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex // Try to place where last active file was if any // Otherwise fallback to user home - return joinPath(this.fileDialogService.defaultFilePath() || (await this.pathService.userHome), suggestedFilename); + return joinPath(this.fileDialogService.defaultFilePath() || (await this.pathService.userHome()), suggestedFilename); } //#endregion diff --git a/src/vs/workbench/test/browser/workbenchTestServices.ts b/src/vs/workbench/test/browser/workbenchTestServices.ts index 48cca5bef2e..1449ad50c1f 100644 --- a/src/vs/workbench/test/browser/workbenchTestServices.ts +++ b/src/vs/workbench/test/browser/workbenchTestServices.ts @@ -1154,7 +1154,7 @@ export class TestPathService implements IPathService { get path() { return Promise.resolve(isWindows ? win32 : posix); } - get userHome() { return Promise.resolve(this.fallbackUserHome); } + async userHome() { return this.fallbackUserHome; } get resolvedUserHome() { return this.fallbackUserHome; } async fileURI(path: string): Promise {