diff options
author | Benjamin Pasero <benjamin.pasero@microsoft.com> | 2022-06-08 09:35:27 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-08 09:35:27 +0300 |
commit | 10e23028a7d7b328f5c20289df4037967bf333b5 (patch) | |
tree | e05662ca16cbc9358dbfdcc961f94174c364a9db | |
parent | 1327d1eb5045d4da849fa2117a8a1c68292a5e6b (diff) |
debt - remove `getBaseLabel` (#151486)
-rw-r--r-- | src/vs/base/common/labels.ts | 26 | ||||
-rw-r--r-- | src/vs/base/test/common/labels.test.ts | 14 | ||||
-rw-r--r-- | src/vs/platform/extensionManagement/common/extensionManagementCLIService.ts | 6 |
3 files changed, 5 insertions, 41 deletions
diff --git a/src/vs/base/common/labels.ts b/src/vs/base/common/labels.ts index 19a6d4f46bc..3a4af59e9dd 100644 --- a/src/vs/base/common/labels.ts +++ b/src/vs/base/common/labels.ts @@ -4,11 +4,10 @@ *--------------------------------------------------------------------------------------------*/ import { firstOrDefault } from 'vs/base/common/arrays'; -import { hasDriveLetter, isRootOrDriveLetter, toSlashes } from 'vs/base/common/extpath'; -import { Schemas } from 'vs/base/common/network'; +import { hasDriveLetter, toSlashes } from 'vs/base/common/extpath'; import { posix, sep, win32 } from 'vs/base/common/path'; import { isMacintosh, isWindows, OperatingSystem, OS } from 'vs/base/common/platform'; -import { basename, extUri, extUriIgnorePathCase } from 'vs/base/common/resources'; +import { extUri, extUriIgnorePathCase } from 'vs/base/common/resources'; import { rtrim, startsWithIgnoreCase } from 'vs/base/common/strings'; import { URI } from 'vs/base/common/uri'; @@ -139,27 +138,6 @@ function getRelativePathLabel(resource: URI, relativePathProvider: IRelativePath return relativePathLabel; } -export function getBaseLabel(resource: URI | string): string; -export function getBaseLabel(resource: URI | string | undefined): string | undefined; -export function getBaseLabel(resource: URI | string | undefined): string | undefined { - if (!resource) { - return undefined; - } - - if (typeof resource === 'string') { - resource = URI.file(resource); - } - - const base = basename(resource) || (resource.scheme === Schemas.file ? resource.fsPath : resource.path) /* can be empty string if '/' is passed in */; - - // convert c: => C: - if (isWindows && isRootOrDriveLetter(base)) { - return normalizeDriveLetter(base); - } - - return base; -} - export function normalizeDriveLetter(path: string, isWindowsOS: boolean = isWindows): string { if (hasDriveLetter(path, isWindowsOS)) { return path.charAt(0).toUpperCase() + path.slice(1); diff --git a/src/vs/base/test/common/labels.test.ts b/src/vs/base/test/common/labels.test.ts index 49cc1699699..82bb2d98a75 100644 --- a/src/vs/base/test/common/labels.test.ts +++ b/src/vs/base/test/common/labels.test.ts @@ -139,20 +139,6 @@ suite('Labels', () => { assert.strictEqual(labels.template(t, { dirty: '* ', activeEditorShort: 'somefile.txt', rootName: 'monaco', appName: 'Visual Studio Code', separator: { label: ' - ' } }), '* somefile.txt - monaco - Visual Studio Code'); }); - (isWindows ? test.skip : test)('getBaseLabel - unix', () => { - assert.strictEqual(labels.getBaseLabel('/some/folder/file.txt'), 'file.txt'); - assert.strictEqual(labels.getBaseLabel('/some/folder'), 'folder'); - assert.strictEqual(labels.getBaseLabel('/'), '/'); - }); - - (!isWindows ? test.skip : test)('getBaseLabel - windows', () => { - assert.strictEqual(labels.getBaseLabel('c:'), 'C:'); - assert.strictEqual(labels.getBaseLabel('c:\\'), 'C:'); - assert.strictEqual(labels.getBaseLabel('c:\\some\\folder\\file.txt'), 'file.txt'); - assert.strictEqual(labels.getBaseLabel('c:\\some\\folder'), 'folder'); - assert.strictEqual(labels.getBaseLabel('c:\\some\\f:older'), 'f:older'); // https://github.com/microsoft/vscode-remote-release/issues/4227 - }); - test('mnemonicButtonLabel', () => { assert.strictEqual(labels.mnemonicButtonLabel('Hello World'), 'Hello World'); assert.strictEqual(labels.mnemonicButtonLabel(''), ''); diff --git a/src/vs/platform/extensionManagement/common/extensionManagementCLIService.ts b/src/vs/platform/extensionManagement/common/extensionManagementCLIService.ts index dc43b23fe1f..d6fe4ceea11 100644 --- a/src/vs/platform/extensionManagement/common/extensionManagementCLIService.ts +++ b/src/vs/platform/extensionManagement/common/extensionManagementCLIService.ts @@ -5,8 +5,8 @@ import { CancellationToken } from 'vs/base/common/cancellation'; import { isCancellationError } from 'vs/base/common/errors'; -import { getBaseLabel } from 'vs/base/common/labels'; import { Schemas } from 'vs/base/common/network'; +import { basename } from 'vs/base/common/resources'; import { gt } from 'vs/base/common/semver/semver'; import { URI } from 'vs/base/common/uri'; import { localize } from 'vs/nls'; @@ -177,11 +177,11 @@ export class ExtensionManagementCLIService implements IExtensionManagementCLISer if (valid) { try { await this.extensionManagementService.install(vsix, installOptions); - output.log(localize('successVsixInstall', "Extension '{0}' was successfully installed.", getBaseLabel(vsix))); + output.log(localize('successVsixInstall', "Extension '{0}' was successfully installed.", basename(vsix))); return manifest; } catch (error) { if (isCancellationError(error)) { - output.log(localize('cancelVsixInstall', "Cancelled installing extension '{0}'.", getBaseLabel(vsix))); + output.log(localize('cancelVsixInstall', "Cancelled installing extension '{0}'.", basename(vsix))); return null; } else { throw error; |