Skip to content

Commit

Permalink
[vscode] support for 'pathSeparator' variable substitution,
Browse files Browse the repository at this point in the history
where ${pathSeparator} - / on macOS or linux, \\ on Windows

Signed-off-by: Alex Gilin <alexander.gilin@sap.com>
  • Loading branch information
alex-gilin committed Feb 24, 2021
1 parent c5f3253 commit 34aeba5
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<void> {
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) => {
Expand Down

0 comments on commit 34aeba5

Please sign in to comment.