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) => {