debt - adopt remote path user home

This commit is contained in:
Benjamin Pasero
2020-04-15 10:45:31 +02:00
parent 53bbba0b8f
commit 8d53e233d8
21 changed files with 173 additions and 104 deletions

View File

@@ -135,7 +135,7 @@ export class LabelService extends Disposable implements ILabelService {
private doGetUriLabel(resource: URI, formatting?: ResourceLabelFormatting, options: { relative?: boolean, noPrefix?: boolean, endWithSeparator?: boolean } = {}): string {
if (!formatting) {
return getPathLabel(resource.path, this.environmentService, options.relative ? this.contextService : undefined);
return getPathLabel(resource.path, { userHome: this.remotePathService.resolvedUserHome }, options.relative ? this.contextService : undefined);
}
let label: string | undefined;
@@ -266,7 +266,7 @@ export class LabelService extends Disposable implements ILabelService {
}
if (formatting.tildify && !forceNoTildify) {
const userHome = this.remotePathService.userHomeSync;
const userHome = this.remotePathService.resolvedUserHome;
if (userHome) {
label = tildify(label, userHome.fsPath);
}

View File

@@ -5,10 +5,7 @@
import * as assert from 'assert';
import { TestEnvironmentService, TestRemotePathService } from 'vs/workbench/test/browser/workbenchTestServices';
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
import { URI } from 'vs/base/common/uri';
import { sep } from 'vs/base/common/path';
import { isWindows } from 'vs/base/common/platform';
import { LabelService } from 'vs/workbench/services/label/common/labelService';
import { TestContextService } from 'vs/workbench/test/common/workbenchTestServices';
@@ -17,28 +14,7 @@ suite('URI Label', () => {
let labelService: LabelService;
setup(() => {
labelService = new LabelService(TestEnvironmentService, new TestContextService(), new TestRemotePathService(TestEnvironmentService));
});
test('file scheme', function () {
labelService.registerFormatter({
scheme: 'file',
formatting: {
label: '${path}',
separator: sep,
tildify: !isWindows,
normalizeDriveLetter: isWindows
}
});
const uri1 = TestWorkspace.folders[0].uri.with({ path: TestWorkspace.folders[0].uri.path.concat('/a/b/c/d') });
assert.equal(labelService.getUriLabel(uri1, { relative: true }), isWindows ? 'a\\b\\c\\d' : 'a/b/c/d');
assert.equal(labelService.getUriLabel(uri1, { relative: false }), isWindows ? 'C:\\testWorkspace\\a\\b\\c\\d' : '/testWorkspace/a/b/c/d');
assert.equal(labelService.getUriBasenameLabel(uri1), 'd');
const uri2 = URI.file('c:\\1/2/3');
assert.equal(labelService.getUriLabel(uri2, { relative: false }), isWindows ? 'C:\\1\\2\\3' : '/c:\\1/2/3');
assert.equal(labelService.getUriBasenameLabel(uri2), '3');
labelService = new LabelService(TestEnvironmentService, new TestContextService(), new TestRemotePathService());
});
test('custom scheme', function () {

View File

@@ -0,0 +1,43 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
import { URI } from 'vs/base/common/uri';
import { sep } from 'vs/base/common/path';
import { isWindows } from 'vs/base/common/platform';
import { LabelService } from 'vs/workbench/services/label/common/labelService';
import { TestContextService } from 'vs/workbench/test/common/workbenchTestServices';
import { TestNativeRemotePathService, TestEnvironmentService } from 'vs/workbench/test/electron-browser/workbenchTestServices';
suite('URI Label', () => {
let labelService: LabelService;
setup(() => {
labelService = new LabelService(TestEnvironmentService, new TestContextService(), new TestNativeRemotePathService(TestEnvironmentService));
});
test('file scheme', function () {
labelService.registerFormatter({
scheme: 'file',
formatting: {
label: '${path}',
separator: sep,
tildify: !isWindows,
normalizeDriveLetter: isWindows
}
});
const uri1 = TestWorkspace.folders[0].uri.with({ path: TestWorkspace.folders[0].uri.path.concat('/a/b/c/d') });
assert.equal(labelService.getUriLabel(uri1, { relative: true }), isWindows ? 'a\\b\\c\\d' : 'a/b/c/d');
assert.equal(labelService.getUriLabel(uri1, { relative: false }), isWindows ? 'C:\\testWorkspace\\a\\b\\c\\d' : '/testWorkspace/a/b/c/d');
assert.equal(labelService.getUriBasenameLabel(uri1), 'd');
const uri2 = URI.file('c:\\1/2/3');
assert.equal(labelService.getUriLabel(uri2, { relative: false }), isWindows ? 'C:\\1\\2\\3' : '/c:\\1/2/3');
assert.equal(labelService.getUriBasenameLabel(uri2), '3');
});
});