Skip to content

Commit 3525505

Browse files
committed
use remote agent service to get remote os
1 parent 28754c8 commit 3525505

1 file changed

Lines changed: 15 additions & 21 deletions

File tree

src/vs/workbench/contrib/remote/common/remote.contribution.ts

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,32 @@ import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as
77
import { Registry } from 'vs/platform/registry/common/platform';
88
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
99
import { ILabelService } from 'vs/platform/label/common/label';
10-
import { isWeb } from 'vs/base/common/platform';
10+
import { isWeb, OperatingSystem } from 'vs/base/common/platform';
1111
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
1212
import { Schemas } from 'vs/base/common/network';
13+
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
1314

1415
export class LabelContribution implements IWorkbenchContribution {
1516
constructor(
1617
@ILabelService private readonly labelService: ILabelService,
17-
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService) {
18+
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
19+
@IRemoteAgentService private readonly remoteAgentService: IRemoteAgentService) {
1820
this.registerFormatters();
1921
}
2022

21-
private useWindowsPaths(): boolean {
22-
if (this.environmentService.configuration.folderUri) {
23-
return this.environmentService.configuration.folderUri.fsPath.indexOf('/') === -1;
24-
}
25-
26-
if (this.environmentService.configuration.workspace) {
27-
return this.environmentService.configuration.workspace.configPath.fsPath.indexOf('/') === -1;
28-
}
29-
30-
return false;
31-
}
32-
3323
private registerFormatters(): void {
3424
if (isWeb) {
35-
this.labelService.registerFormatter({
36-
scheme: Schemas.vscodeRemote,
37-
authority: this.environmentService.configuration.remoteAuthority,
38-
formatting: {
39-
label: '${path}',
40-
separator: this.useWindowsPaths() ? '\\' : '/',
41-
tildify: !this.useWindowsPaths()
25+
this.remoteAgentService.getEnvironment().then(remoteEnvironment => {
26+
if (remoteEnvironment) {
27+
this.labelService.registerFormatter({
28+
scheme: Schemas.vscodeRemote,
29+
authority: this.environmentService.configuration.remoteAuthority,
30+
formatting: {
31+
label: '${path}',
32+
separator: remoteEnvironment.os === OperatingSystem.Windows ? '\\' : '/',
33+
tildify: remoteEnvironment.os !== OperatingSystem.Windows
34+
}
35+
});
4236
}
4337
});
4438
}

0 commit comments

Comments
 (0)