From a06dbfc3f2a0a69a890583bc77abd36567d5864e Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Fri, 15 Feb 2019 16:08:34 +0100 Subject: [PATCH] rename extpath.normalize to extpath.normalizeWithSlash --- src/vs/base/common/extpath.ts | 12 +-- src/vs/base/common/resources.ts | 2 +- src/vs/base/test/common/extpath.test.ts | 88 +++++++++---------- .../platform/workspaces/common/workspaces.ts | 4 +- src/vs/workbench/api/node/extHostWorkspace.ts | 25 +++--- src/vs/workbench/common/resources.ts | 8 +- .../output/common/outputLinkComputer.ts | 2 +- .../search/browser/search.contribution.ts | 5 +- .../contrib/search/browser/searchView.ts | 12 +-- .../configuration/node/configuration.ts | 13 +-- .../services/themes/browser/colorThemeData.ts | 4 +- .../api/extHostWorkspace.test.ts | 15 ++-- 12 files changed, 87 insertions(+), 103 deletions(-) diff --git a/src/vs/base/common/extpath.ts b/src/vs/base/common/extpath.ts index b2d2b2ec14c..63e51a0dc1c 100644 --- a/src/vs/base/common/extpath.ts +++ b/src/vs/base/common/extpath.ts @@ -26,14 +26,14 @@ function _isNormal(path: string, win: boolean): boolean { * This should only be done for OS paths from Windows (or user provided paths potentially from Windows). * Using it on a Linux or MaxOS path might change it. */ -export function toForwardSlashes(osPath: string) { +export function toSlashes(osPath: string) { return osPath.replace(/[\\/]/g, '/'); } -export function normalize(path: undefined): undefined; -export function normalize(path: null): null; -export function normalize(path: string): string; -export function normalize(path: string | null | undefined): string | null | undefined { +export function normalizeWithSlashes(path: undefined): undefined; +export function normalizeWithSlashes(path: null): null; +export function normalizeWithSlashes(path: string): string; +export function normalizeWithSlashes(path: string | null | undefined): string | null | undefined { if (path === null || path === undefined) { return path; @@ -115,7 +115,7 @@ export const join: (...parts: string[]) => string = function () { value += part; } - return normalize(value); + return normalizeWithSlashes(value); }; diff --git a/src/vs/base/common/resources.ts b/src/vs/base/common/resources.ts index 7e449cbd744..cd8f2e3f3d4 100644 --- a/src/vs/base/common/resources.ts +++ b/src/vs/base/common/resources.ts @@ -204,7 +204,7 @@ export function relativePath(from: URI, to: URI): string | undefined { } if (from.scheme === Schemas.file) { const relativePath = paths.relative(from.path, to.path); - return isWindows ? extpath.toForwardSlashes(relativePath) : relativePath; + return isWindows ? extpath.toSlashes(relativePath) : relativePath; } return paths.posix.relative(from.path || '/', to.path || '/'); } diff --git a/src/vs/base/test/common/extpath.test.ts b/src/vs/base/test/common/extpath.test.ts index c97a8bd7ff9..82364657387 100644 --- a/src/vs/base/test/common/extpath.test.ts +++ b/src/vs/base/test/common/extpath.test.ts @@ -9,54 +9,54 @@ import * as platform from 'vs/base/common/platform'; suite('Paths', () => { test('toForwardSlashes', () => { - assert.equal(extpath.toForwardSlashes('\\\\server\\share\\some\\path'), '//server/share/some/path'); - assert.equal(extpath.toForwardSlashes('c:\\test'), 'c:/test'); - assert.equal(extpath.toForwardSlashes('foo\\bar'), 'foo/bar'); - assert.equal(extpath.toForwardSlashes('/user/far'), '/user/far'); + assert.equal(extpath.toSlashes('\\\\server\\share\\some\\path'), '//server/share/some/path'); + assert.equal(extpath.toSlashes('c:\\test'), 'c:/test'); + assert.equal(extpath.toSlashes('foo\\bar'), 'foo/bar'); + assert.equal(extpath.toSlashes('/user/far'), '/user/far'); }); test('normalize', () => { - assert.equal(extpath.normalize(''), '.'); - assert.equal(extpath.normalize('.'), '.'); - assert.equal(extpath.normalize('.'), '.'); - assert.equal(extpath.normalize('../../far'), '../../far'); - assert.equal(extpath.normalize('../bar'), '../bar'); - assert.equal(extpath.normalize('../far'), '../far'); - assert.equal(extpath.normalize('./'), './'); - assert.equal(extpath.normalize('./././'), './'); - assert.equal(extpath.normalize('./ff/./'), 'ff/'); - assert.equal(extpath.normalize('./foo'), 'foo'); - assert.equal(extpath.normalize('/'), '/'); - assert.equal(extpath.normalize('/..'), '/'); - assert.equal(extpath.normalize('///'), '/'); - assert.equal(extpath.normalize('//foo'), '/foo'); - assert.equal(extpath.normalize('//foo//'), '/foo/'); - assert.equal(extpath.normalize('/foo'), '/foo'); - assert.equal(extpath.normalize('/foo/bar.test'), '/foo/bar.test'); - assert.equal(extpath.normalize('\\\\\\'), '/'); - assert.equal(extpath.normalize('c:/../ff'), 'c:/ff'); - assert.equal(extpath.normalize('c:\\./'), 'c:/'); - assert.equal(extpath.normalize('foo/'), 'foo/'); - assert.equal(extpath.normalize('foo/../../bar'), '../bar'); - assert.equal(extpath.normalize('foo/./'), 'foo/'); - assert.equal(extpath.normalize('foo/./bar'), 'foo/bar'); - assert.equal(extpath.normalize('foo//'), 'foo/'); - assert.equal(extpath.normalize('foo//'), 'foo/'); - assert.equal(extpath.normalize('foo//bar'), 'foo/bar'); - assert.equal(extpath.normalize('foo//bar/far'), 'foo/bar/far'); - assert.equal(extpath.normalize('foo/bar/../../far'), 'far'); - assert.equal(extpath.normalize('foo/bar/../far'), 'foo/far'); - assert.equal(extpath.normalize('foo/far/../../bar'), 'bar'); - assert.equal(extpath.normalize('foo/far/../../bar'), 'bar'); - assert.equal(extpath.normalize('foo/xxx/..'), 'foo'); - assert.equal(extpath.normalize('foo/xxx/../bar'), 'foo/bar'); - assert.equal(extpath.normalize('foo/xxx/./..'), 'foo'); - assert.equal(extpath.normalize('foo/xxx/./../bar'), 'foo/bar'); - assert.equal(extpath.normalize('foo/xxx/./bar'), 'foo/xxx/bar'); - assert.equal(extpath.normalize('foo\\bar'), 'foo/bar'); - assert.equal(extpath.normalize(null), null); - assert.equal(extpath.normalize(undefined), undefined); + assert.equal(extpath.normalizeWithSlashes(''), '.'); + assert.equal(extpath.normalizeWithSlashes('.'), '.'); + assert.equal(extpath.normalizeWithSlashes('.'), '.'); + assert.equal(extpath.normalizeWithSlashes('../../far'), '../../far'); + assert.equal(extpath.normalizeWithSlashes('../bar'), '../bar'); + assert.equal(extpath.normalizeWithSlashes('../far'), '../far'); + assert.equal(extpath.normalizeWithSlashes('./'), './'); + assert.equal(extpath.normalizeWithSlashes('./././'), './'); + assert.equal(extpath.normalizeWithSlashes('./ff/./'), 'ff/'); + assert.equal(extpath.normalizeWithSlashes('./foo'), 'foo'); + assert.equal(extpath.normalizeWithSlashes('/'), '/'); + assert.equal(extpath.normalizeWithSlashes('/..'), '/'); + assert.equal(extpath.normalizeWithSlashes('///'), '/'); + assert.equal(extpath.normalizeWithSlashes('//foo'), '/foo'); + assert.equal(extpath.normalizeWithSlashes('//foo//'), '/foo/'); + assert.equal(extpath.normalizeWithSlashes('/foo'), '/foo'); + assert.equal(extpath.normalizeWithSlashes('/foo/bar.test'), '/foo/bar.test'); + assert.equal(extpath.normalizeWithSlashes('\\\\\\'), '/'); + assert.equal(extpath.normalizeWithSlashes('c:/../ff'), 'c:/ff'); + assert.equal(extpath.normalizeWithSlashes('c:\\./'), 'c:/'); + assert.equal(extpath.normalizeWithSlashes('foo/'), 'foo/'); + assert.equal(extpath.normalizeWithSlashes('foo/../../bar'), '../bar'); + assert.equal(extpath.normalizeWithSlashes('foo/./'), 'foo/'); + assert.equal(extpath.normalizeWithSlashes('foo/./bar'), 'foo/bar'); + assert.equal(extpath.normalizeWithSlashes('foo//'), 'foo/'); + assert.equal(extpath.normalizeWithSlashes('foo//'), 'foo/'); + assert.equal(extpath.normalizeWithSlashes('foo//bar'), 'foo/bar'); + assert.equal(extpath.normalizeWithSlashes('foo//bar/far'), 'foo/bar/far'); + assert.equal(extpath.normalizeWithSlashes('foo/bar/../../far'), 'far'); + assert.equal(extpath.normalizeWithSlashes('foo/bar/../far'), 'foo/far'); + assert.equal(extpath.normalizeWithSlashes('foo/far/../../bar'), 'bar'); + assert.equal(extpath.normalizeWithSlashes('foo/far/../../bar'), 'bar'); + assert.equal(extpath.normalizeWithSlashes('foo/xxx/..'), 'foo'); + assert.equal(extpath.normalizeWithSlashes('foo/xxx/../bar'), 'foo/bar'); + assert.equal(extpath.normalizeWithSlashes('foo/xxx/./..'), 'foo'); + assert.equal(extpath.normalizeWithSlashes('foo/xxx/./../bar'), 'foo/bar'); + assert.equal(extpath.normalizeWithSlashes('foo/xxx/./bar'), 'foo/xxx/bar'); + assert.equal(extpath.normalizeWithSlashes('foo\\bar'), 'foo/bar'); + assert.equal(extpath.normalizeWithSlashes(null), null); + assert.equal(extpath.normalizeWithSlashes(undefined), undefined); // https://github.com/Microsoft/vscode/issues/7234 assert.equal(extpath.join('/home/aeschli/workspaces/vscode/extensions/css', './syntaxes/css.plist'), '/home/aeschli/workspaces/vscode/extensions/css/syntaxes/css.plist'); diff --git a/src/vs/platform/workspaces/common/workspaces.ts b/src/vs/platform/workspaces/common/workspaces.ts index 6f4f7b7d7d2..3a1a6e7189a 100644 --- a/src/vs/platform/workspaces/common/workspaces.ts +++ b/src/vs/platform/workspaces/common/workspaces.ts @@ -8,7 +8,7 @@ import { localize } from 'vs/nls'; import { Event } from 'vs/base/common/event'; import { IWorkspaceFolder, IWorkspace } from 'vs/platform/workspace/common/workspace'; import { URI, UriComponents } from 'vs/base/common/uri'; -import { isEqualOrParent, normalize } from 'vs/base/common/extpath'; +import { isEqualOrParent, normalizeWithSlashes } from 'vs/base/common/extpath'; import { isWindows, isLinux, isMacintosh } from 'vs/base/common/platform'; import { isAbsolute, relative, posix, resolve, extname } from 'vs/base/common/path'; import { normalizeDriveLetter } from 'vs/base/common/labels'; @@ -179,7 +179,7 @@ export function massageFolderPathForWorkspace(absoluteFolderPath: string, target if (isWindows) { if (isAbsolute(absoluteFolderPath)) { if (shouldUseSlashForPath(existingFolders)) { - absoluteFolderPath = normalize(absoluteFolderPath /* do not use OS path separator */); + absoluteFolderPath = normalizeWithSlashes(absoluteFolderPath /* do not use OS path separator */); } absoluteFolderPath = normalizeDriveLetter(absoluteFolderPath); diff --git a/src/vs/workbench/api/node/extHostWorkspace.ts b/src/vs/workbench/api/node/extHostWorkspace.ts index 40c7aa35dd7..9f85c4fa2aa 100644 --- a/src/vs/workbench/api/node/extHostWorkspace.ts +++ b/src/vs/workbench/api/node/extHostWorkspace.ts @@ -3,15 +3,14 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { join, relative } from 'vs/base/common/path'; +import { join } from 'vs/base/common/path'; import { delta as arrayDelta, mapArrayOrNot } from 'vs/base/common/arrays'; import { CancellationToken } from 'vs/base/common/cancellation'; import { Emitter, Event } from 'vs/base/common/event'; import { TernarySearchTree } from 'vs/base/common/map'; import { Counter } from 'vs/base/common/numbers'; -import { normalize } from 'vs/base/common/extpath'; import { isLinux } from 'vs/base/common/platform'; -import { basenameOrAuthority, dirname, isEqual } from 'vs/base/common/resources'; +import { basenameOrAuthority, dirname, isEqual, relativePath } from 'vs/base/common/resources'; import { compare } from 'vs/base/common/strings'; import { URI } from 'vs/base/common/uri'; import { localize } from 'vs/nls'; @@ -326,35 +325,35 @@ export class ExtHostWorkspaceProvider { getRelativePath(pathOrUri: string | vscode.Uri, includeWorkspace?: boolean): string | undefined { - let path: string | undefined; + let resource: URI | undefined; if (typeof pathOrUri === 'string') { - path = pathOrUri; + resource = URI.file(pathOrUri); } else if (typeof pathOrUri !== 'undefined') { - path = pathOrUri.fsPath; + resource = pathOrUri; } - if (!path) { - return path; + if (!resource) { + return undefined; } const folder = this.getWorkspaceFolder( - typeof pathOrUri === 'string' ? URI.file(pathOrUri) : pathOrUri, + resource, true ); if (!folder) { - return path; + return resource.fsPath; } if (typeof includeWorkspace === 'undefined' && this._actualWorkspace) { includeWorkspace = this._actualWorkspace.folders.length > 1; } - let result = relative(folder.uri.fsPath, path); - if (includeWorkspace) { + let result = relativePath(folder.uri, resource); + if (includeWorkspace && folder.name) { result = `${folder.name}/${result}`; } - return normalize(result); + return result; } private trySetWorkspaceFolders(folders: vscode.WorkspaceFolder[]): void { diff --git a/src/vs/workbench/common/resources.ts b/src/vs/workbench/common/resources.ts index 35059880637..59da1881f15 100644 --- a/src/vs/workbench/common/resources.ts +++ b/src/vs/workbench/common/resources.ts @@ -4,11 +4,9 @@ *--------------------------------------------------------------------------------------------*/ import { URI } from 'vs/base/common/uri'; -import * as extpath from 'vs/base/common/extpath'; import * as objects from 'vs/base/common/objects'; import { Event, Emitter } from 'vs/base/common/event'; -import { relative } from 'vs/base/common/path'; -import { basename, extname } from 'vs/base/common/resources'; +import { basename, extname, relativePath } from 'vs/base/common/resources'; import { RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey'; import { IModeService } from 'vs/editor/common/services/modeService'; import { IFileService } from 'vs/platform/files/common/files'; @@ -197,9 +195,9 @@ export class ResourceGlobMatcher extends Disposable { // but can match on "src/file.txt" let resourcePathToMatch: string; if (folder) { - resourcePathToMatch = extpath.normalize(relative(folder.uri.fsPath, resource.fsPath)); + resourcePathToMatch = relativePath(folder.uri, resource); // always uses forward slashes } else { - resourcePathToMatch = resource.fsPath; + resourcePathToMatch = resource.fsPath; // TODO@isidor: support non-file URIs } return !!expressionForRoot(resourcePathToMatch); diff --git a/src/vs/workbench/contrib/output/common/outputLinkComputer.ts b/src/vs/workbench/contrib/output/common/outputLinkComputer.ts index 87e8852d848..10cb01e71bf 100644 --- a/src/vs/workbench/contrib/output/common/outputLinkComputer.ts +++ b/src/vs/workbench/contrib/output/common/outputLinkComputer.ts @@ -90,7 +90,7 @@ export class OutputLinkComputer { const workspaceFolderPath = workspaceFolder.scheme === 'file' ? workspaceFolder.fsPath : workspaceFolder.path; const workspaceFolderVariants = arrays.distinct([ path.normalize(workspaceFolderPath), - extpath.normalize(workspaceFolderPath) + extpath.normalizeWithSlashes(workspaceFolderPath) ]); workspaceFolderVariants.forEach(workspaceFolderVariant => { diff --git a/src/vs/workbench/contrib/search/browser/search.contribution.ts b/src/vs/workbench/contrib/search/browser/search.contribution.ts index c1caea124b3..3aec6b57323 100644 --- a/src/vs/workbench/contrib/search/browser/search.contribution.ts +++ b/src/vs/workbench/contrib/search/browser/search.contribution.ts @@ -5,7 +5,6 @@ import 'vs/css!./media/search.contribution'; -import { relative } from 'vs/base/common/path'; import { Action } from 'vs/base/common/actions'; import { distinct } from 'vs/base/common/arrays'; import { illegalArgument } from 'vs/base/common/errors'; @@ -358,7 +357,7 @@ const searchInFolderCommand: ICommandHandler = (accessor, resource?: URI) => { } }); - searchView.searchInFolders(distinct(folders, folder => folder.toString()), (from, to) => relative(from, to)); + searchView.searchInFolders(distinct(folders, folder => folder.toString())); }); } @@ -394,7 +393,7 @@ CommandsRegistry.registerCommand({ id: FIND_IN_WORKSPACE_ID, handler: (accessor) => { return openSearchView(accessor.get(IViewletService), accessor.get(IPanelService), true).then(searchView => { - searchView.searchInFolders(null, (from, to) => relative(from, to)); + searchView.searchInFolders(null); }); } }); diff --git a/src/vs/workbench/contrib/search/browser/searchView.ts b/src/vs/workbench/contrib/search/browser/searchView.ts index 2260ff75ef4..d42b05482b7 100644 --- a/src/vs/workbench/contrib/search/browser/searchView.ts +++ b/src/vs/workbench/contrib/search/browser/searchView.ts @@ -17,7 +17,6 @@ import { Emitter, Event } from 'vs/base/common/event'; import { Iterator } from 'vs/base/common/iterator'; import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { dispose, IDisposable } from 'vs/base/common/lifecycle'; -import * as extpath from 'vs/base/common/extpath'; import * as env from 'vs/base/common/platform'; import * as strings from 'vs/base/common/strings'; import { URI } from 'vs/base/common/uri'; @@ -62,6 +61,7 @@ import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editor import { IPartService } from 'vs/workbench/services/part/common/partService'; import { IPreferencesService, ISettingsEditorOptions } from 'vs/workbench/services/preferences/common/preferences'; import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; +import { relativePath } from 'vs/base/common/resources'; const $ = dom.$; @@ -1076,7 +1076,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { } } - searchInFolders(resources: URI[], pathToRelative: (from: string, to: string) => string): void { + searchInFolders(resources: URI[]): void { const folderPaths: string[] = []; const workspace = this.contextService.getWorkspace(); @@ -1085,7 +1085,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { let folderPath: string | undefined; if (this.contextService.getWorkbenchState() === WorkbenchState.FOLDER) { // Show relative path from the root for single-root mode - folderPath = extpath.normalize(pathToRelative(workspace.folders[0].uri.fsPath, resource.fsPath)); + folderPath = relativePath(workspace.folders[0].uri, resource); // always uses forward slashes if (folderPath && folderPath !== '.') { folderPath = './' + folderPath; } @@ -1097,14 +1097,14 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { // If this root is the only one with its basename, use a relative ./ path. If there is another, use an absolute path const isUniqueFolder = workspace.folders.filter(folder => folder.name === owningRootName).length === 1; if (isUniqueFolder) { - const relativePath = extpath.normalize(pathToRelative(owningFolder.uri.fsPath, resource.fsPath)); - if (relativePath === '.') { + const relPath = relativePath(owningFolder.uri, resource); // always uses forward slashes + if (relPath === '') { folderPath = `./${owningFolder.name}`; } else { folderPath = `./${owningFolder.name}/${relativePath}`; } } else { - folderPath = resource.fsPath; + folderPath = resource.fsPath; // TODO rob: handle on-file URIs } } } diff --git a/src/vs/workbench/services/configuration/node/configuration.ts b/src/vs/workbench/services/configuration/node/configuration.ts index f4af79b7afb..df26c2f9309 100644 --- a/src/vs/workbench/services/configuration/node/configuration.ts +++ b/src/vs/workbench/services/configuration/node/configuration.ts @@ -14,7 +14,6 @@ import * as collections from 'vs/base/common/collections'; import { Disposable, IDisposable, dispose } from 'vs/base/common/lifecycle'; import { RunOnceScheduler, Delayer } from 'vs/base/common/async'; import { FileChangeType, FileChangesEvent, IContent, IFileService } from 'vs/platform/files/common/files'; -import { isLinux } from 'vs/base/common/platform'; import { ConfigurationModel } from 'vs/platform/configuration/common/configurationModels'; import { WorkspaceConfigurationModelParser, FolderSettingsModelParser, StandaloneConfigurationModelParser } from 'vs/workbench/services/configuration/common/configurationModels'; import { FOLDER_SETTINGS_PATH, TASKS_CONFIGURATION_KEY, FOLDER_SETTINGS_NAME, LAUNCH_CONFIGURATION_KEY } from 'vs/workbench/services/configuration/common/configuration'; @@ -23,7 +22,7 @@ import * as extfs from 'vs/base/node/extfs'; import { JSONEditingService } from 'vs/workbench/services/configuration/node/jsonEditingService'; import { WorkbenchState, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace'; import { ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry'; -import { relative, extname } from 'vs/base/common/path'; +import { extname } from 'vs/base/common/path'; import { equals } from 'vs/base/common/objects'; import { Schemas } from 'vs/base/common/network'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; @@ -530,14 +529,8 @@ export class FileServiceBasedFolderConfiguration extends AbstractFolderConfigura } private toFolderRelativePath(resource: URI): string | null { - if (resource.scheme === Schemas.file) { - if (extpath.isEqualOrParent(resource.fsPath, this.folderConfigurationPath.fsPath, !isLinux /* ignorecase */)) { - return extpath.normalize(relative(this.folderConfigurationPath.fsPath, resource.fsPath)); - } - } else { - if (resources.isEqualOrParent(resource, this.folderConfigurationPath)) { - return extpath.normalize(relative(this.folderConfigurationPath.path, resource.path)); - } + if (resources.isEqualOrParent(resource, this.folderConfigurationPath)) { + return resources.relativePath(this.folderConfigurationPath, resource); } return null; } diff --git a/src/vs/workbench/services/themes/browser/colorThemeData.ts b/src/vs/workbench/services/themes/browser/colorThemeData.ts index 4aaa7b918f2..3d4401e05f8 100644 --- a/src/vs/workbench/services/themes/browser/colorThemeData.ts +++ b/src/vs/workbench/services/themes/browser/colorThemeData.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as Extpath from 'vs/base/common/extpath'; +import { toSlashes } from 'vs/base/common/extpath'; import { basename } from 'vs/base/common/path'; import * as Json from 'vs/base/common/json'; import { Color } from 'vs/base/common/color'; @@ -260,7 +260,7 @@ export class ColorThemeData implements IColorTheme { static fromExtensionTheme(theme: IThemeExtensionPoint, colorThemeLocation: URI, extensionData: ExtensionData): ColorThemeData { let baseTheme: string = theme['uiTheme'] || 'vs-dark'; - let themeSelector = toCSSSelector(extensionData.extensionId + '-' + Extpath.normalize(theme.path)); + let themeSelector = toCSSSelector(extensionData.extensionId + '-' + toSlashes(theme.path)); let themeData = new ColorThemeData(); themeData.id = `${baseTheme} ${themeSelector}`; themeData.label = theme.label || basename(theme.path); diff --git a/src/vs/workbench/test/electron-browser/api/extHostWorkspace.test.ts b/src/vs/workbench/test/electron-browser/api/extHostWorkspace.test.ts index 71af366811b..8cc4279dfd9 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostWorkspace.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostWorkspace.test.ts @@ -8,7 +8,6 @@ import { URI } from 'vs/base/common/uri'; import { basename } from 'vs/base/common/path'; import { ExtHostWorkspaceProvider } from 'vs/workbench/api/node/extHostWorkspace'; import { TestRPCProtocol } from './testRPCProtocol'; -import { normalize } from 'vs/base/common/extpath'; import { IWorkspaceFolderData } from 'vs/platform/workspace/common/workspace'; import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions'; import { NullLogService } from 'vs/platform/log/common/log'; @@ -32,11 +31,7 @@ suite('ExtHostWorkspace', function () { function assertAsRelativePath(workspace: ExtHostWorkspaceProvider, input: string, expected: string, includeWorkspace?: boolean) { const actual = workspace.getRelativePath(input, includeWorkspace); - if (actual === expected) { - assert.ok(true); - } else { - assert.equal(actual, normalize(expected)); - } + assert.equal(actual, expected); } test('asRelativePath', () => { @@ -57,16 +52,16 @@ suite('ExtHostWorkspace', function () { const input = '/home/aeschli/workspaces/samples/docker'; const ws = new ExtHostWorkspaceProvider(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService(), new Counter()); - assertAsRelativePath(ws, (input), input); + assertAsRelativePath(ws, input, input); const input2 = '/home/aeschli/workspaces/samples/docker/a.file'; - assertAsRelativePath(ws, (input2), 'a.file'); + assertAsRelativePath(ws, input2, 'a.file'); }); test('asRelativePath, no workspace', function () { const ws = new ExtHostWorkspaceProvider(new TestRPCProtocol(), null!, new NullLogService(), new Counter()); - assertAsRelativePath(ws, (''), ''); - assertAsRelativePath(ws, ('/foo/bar'), '/foo/bar'); + assertAsRelativePath(ws, '', ''); + assertAsRelativePath(ws, '/foo/bar', '/foo/bar'); }); test('asRelativePath, multiple folders', function () {