diff --git a/src/vs/platform/environment/common/environment.ts b/src/vs/platform/environment/common/environment.ts index ee908ae2dddc4..f5c2a93524724 100644 --- a/src/vs/platform/environment/common/environment.ts +++ b/src/vs/platform/environment/common/environment.ts @@ -124,6 +124,7 @@ export interface IEnvironmentService extends IUserHomeProvider { keybindingsResource: URI; keyboardLayoutResource: URI; argvResource: URI; + snippetsHome: URI; // sync resources userDataSyncLogResource: URI; diff --git a/src/vs/platform/environment/node/environmentService.ts b/src/vs/platform/environment/node/environmentService.ts index 07c266d77a145..55ed6cb34e186 100644 --- a/src/vs/platform/environment/node/environmentService.ts +++ b/src/vs/platform/environment/node/environmentService.ts @@ -142,6 +142,9 @@ export class EnvironmentService implements IEnvironmentService { return URI.file(path.join(this.userHome, product.dataFolderName, 'argv.json')); } + @memoize + get snippetsHome(): URI { return resources.joinPath(this.userRoamingDataHome, 'snippets'); } + @memoize get isExtensionDevelopment(): boolean { return !!this._args.extensionDevelopmentPath; } diff --git a/src/vs/workbench/contrib/snippets/browser/configureSnippets.ts b/src/vs/workbench/contrib/snippets/browser/configureSnippets.ts index 7906d62de808d..755b5b40fed72 100644 --- a/src/vs/workbench/contrib/snippets/browser/configureSnippets.ts +++ b/src/vs/workbench/contrib/snippets/browser/configureSnippets.ts @@ -87,7 +87,7 @@ async function computePicks(snippetService: ISnippetsService, envService: IEnvir } } - const dir = joinPath(envService.userRoamingDataHome, 'snippets'); + const dir = envService.snippetsHome; for (const mode of modeService.getRegisteredModes()) { const label = modeService.getLanguageName(mode); if (label && !seen.has(mode)) { @@ -219,7 +219,7 @@ CommandsRegistry.registerCommand(id, async (accessor): Promise => { const globalSnippetPicks: SnippetPick[] = [{ scope: nls.localize('new.global_scope', 'global'), label: nls.localize('new.global', "New Global Snippets file..."), - uri: joinPath(envService.userRoamingDataHome, 'snippets') + uri: envService.snippetsHome }]; const workspaceSnippetPicks: SnippetPick[] = []; diff --git a/src/vs/workbench/contrib/snippets/browser/snippetsService.ts b/src/vs/workbench/contrib/snippets/browser/snippetsService.ts index f97863e239892..0355799e9ad63 100644 --- a/src/vs/workbench/contrib/snippets/browser/snippetsService.ts +++ b/src/vs/workbench/contrib/snippets/browser/snippetsService.ts @@ -289,7 +289,7 @@ class SnippetsService implements ISnippetsService { } private _initUserSnippets(): Promise { - const userSnippetsFolder = resources.joinPath(this._environmentService.userRoamingDataHome, 'snippets'); + const userSnippetsFolder = this._environmentService.snippetsHome; return this._fileService.createFolder(userSnippetsFolder).then(() => this._initFolderSnippets(SnippetSource.User, userSnippetsFolder, this._disposables)); } diff --git a/src/vs/workbench/contrib/telemetry/browser/telemetry.contribution.ts b/src/vs/workbench/contrib/telemetry/browser/telemetry.contribution.ts index ee6a1f86d1e68..bd8c574e3d5f1 100644 --- a/src/vs/workbench/contrib/telemetry/browser/telemetry.contribution.ts +++ b/src/vs/workbench/contrib/telemetry/browser/telemetry.contribution.ts @@ -20,7 +20,7 @@ import { configurationTelemetry } from 'vs/platform/telemetry/common/telemetryUt import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; import { ITextFileService, ITextFileSaveEvent, ITextFileLoadEvent } from 'vs/workbench/services/textfile/common/textfiles'; -import { extname, basename, isEqual, isEqualOrParent, joinPath } from 'vs/base/common/resources'; +import { extname, basename, isEqual, isEqualOrParent } from 'vs/base/common/resources'; import { URI } from 'vs/base/common/uri'; import { Schemas } from 'vs/base/common/network'; import { guessMimeTypes } from 'vs/base/common/mime'; @@ -175,7 +175,7 @@ export class TelemetryContribution extends Disposable implements IWorkbenchContr } // Check for snippets - if (isEqualOrParent(resource, joinPath(this.environmentService.userRoamingDataHome, 'snippets'))) { + if (isEqualOrParent(resource, this.environmentService.snippetsHome)) { return 'snippets'; } diff --git a/src/vs/workbench/services/environment/browser/environmentService.ts b/src/vs/workbench/services/environment/browser/environmentService.ts index a4ee8d92f87b1..93e05e6d14a9d 100644 --- a/src/vs/workbench/services/environment/browser/environmentService.ts +++ b/src/vs/workbench/services/environment/browser/environmentService.ts @@ -102,6 +102,9 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment @memoize get argvResource(): URI { return joinPath(this.userRoamingDataHome, 'argv.json'); } + @memoize + get snippetsHome(): URI { return joinPath(this.userRoamingDataHome, 'snippets'); } + @memoize get userDataSyncHome(): URI { return joinPath(this.userRoamingDataHome, 'sync'); }