From 34aeba532c12bbe717bc5f6c45765dfdc1b6a35c Mon Sep 17 00:00:00 2001 From: alexander gilin Date: Thu, 11 Feb 2021 09:59:20 +0200 Subject: [PATCH] [vscode] support for 'pathSeparator' variable substitution, where ${pathSeparator} - / on macOS or linux, \\ on Windows Signed-off-by: Alex Gilin --- .../src/browser/common-variable-contribution.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/variable-resolver/src/browser/common-variable-contribution.ts b/packages/variable-resolver/src/browser/common-variable-contribution.ts index 318f87d3c32a3..8afac0905435d 100644 --- a/packages/variable-resolver/src/browser/common-variable-contribution.ts +++ b/packages/variable-resolver/src/browser/common-variable-contribution.ts @@ -16,8 +16,10 @@ import { injectable, inject } from 'inversify'; import { VariableContribution, VariableRegistry } from './variable'; +import { ApplicationServer } from '@theia/core/lib/common/application-protocol'; import { EnvVariablesServer } from '@theia/core/lib/common/env-variables'; import { CommandService } from '@theia/core/lib/common/command'; +import { OS } from '@theia/core/lib/common/os'; import { PreferenceService } from '@theia/core/lib/browser/preferences/preference-service'; import { ResourceContextKey } from '@theia/core/lib/browser/resource-context-key'; import { VariableInput } from './variable-input'; @@ -46,12 +48,22 @@ export class CommonVariableContribution implements VariableContribution { @inject(QuickPickService) protected readonly quickPickService: QuickPickService; + @inject(ApplicationServer) + protected readonly appServer: ApplicationServer; + async registerVariables(variables: VariableRegistry): Promise { - const execPath = await this.env.getExecPath(); + const [execPath, backendOS] = await Promise.all([ + this.env.getExecPath(), + this.appServer.getBackendOS() + ]); variables.registerVariable({ name: 'execPath', resolve: () => execPath }); + variables.registerVariable({ + name: 'pathSeparator', + resolve: () => backendOS === OS.Type.Windows ? '\\' : '/' + }); variables.registerVariable({ name: 'env', resolve: async (_, envVariableName) => {