Skip to content

Commit

Permalink
#86678 define snippets home property in env service
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Mar 19, 2020
1 parent 6e06490 commit f50e303
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/vs/platform/environment/common/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export interface IEnvironmentService extends IUserHomeProvider {
keybindingsResource: URI;
keyboardLayoutResource: URI;
argvResource: URI;
snippetsHome: URI;

// sync resources
userDataSyncLogResource: URI;
Expand Down
3 changes: 3 additions & 0 deletions src/vs/platform/environment/node/environmentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -219,7 +219,7 @@ CommandsRegistry.registerCommand(id, async (accessor): Promise<any> => {
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[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class SnippetsService implements ISnippetsService {
}

private _initUserSnippets(): Promise<any> {
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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'); }

Expand Down

0 comments on commit f50e303

Please sign in to comment.