diff --git a/src/vs/base/common/labels.ts b/src/vs/base/common/labels.ts index e1227fb2642..6b9dbb4c92b 100644 --- a/src/vs/base/common/labels.ts +++ b/src/vs/base/common/labels.ts @@ -45,7 +45,7 @@ export function getPathLabel(resource: URI | string, basePathProvider?: URI | st const basepath = basePathProvider && getPath(basePathProvider); - if (basepath && isEqualOrParent(absolutePath, basepath)) { + if (basepath && isEqualOrParent(absolutePath, basepath, !platform.isLinux /* ignorecase */)) { if (basepath === absolutePath) { return ''; // no label if pathes are identical } diff --git a/src/vs/base/common/map.ts b/src/vs/base/common/map.ts index 2f81619a09c..7563aa5b98d 100644 --- a/src/vs/base/common/map.ts +++ b/src/vs/base/common/map.ts @@ -7,7 +7,6 @@ import URI from 'vs/base/common/uri'; import { Schemas } from 'vs/base/common/network'; -import { isLinux } from 'vs/base/common/platform'; export interface Key { toString(): string; @@ -411,7 +410,7 @@ export class TrieMap { export class ResourceMap { private map: Map; - constructor() { + constructor(private ignoreCase?: boolean) { this.map = new Map(); } @@ -455,14 +454,14 @@ export class ResourceMap { if (resource.scheme === Schemas.file) { key = resource.fsPath; - - if (!isLinux) { - key = key.toLowerCase(); - } } else { key = resource.toString(); } + if (this.ignoreCase) { + key = key.toLowerCase(); + } + return key; } } \ No newline at end of file diff --git a/src/vs/base/test/common/map.test.ts b/src/vs/base/test/common/map.test.ts index 19dc49c2d21..c104521aef0 100644 --- a/src/vs/base/test/common/map.test.ts +++ b/src/vs/base/test/common/map.test.ts @@ -402,8 +402,8 @@ suite('Map', () => { assert.ok(map.has(resource2)); }); - test('ResourceMap - files', function () { - const map = new ResourceMap(); + test('ResourceMap - files (ignorecase)', function () { + const map = new ResourceMap(true); const fileA = URI.parse('file://some/filea'); const fileB = URI.parse('some://some/other/fileb'); diff --git a/src/vs/code/electron-main/windows.ts b/src/vs/code/electron-main/windows.ts index 8cd4171ce55..cf432421472 100644 --- a/src/vs/code/electron-main/windows.ts +++ b/src/vs/code/electron-main/windows.ts @@ -234,8 +234,8 @@ export class WindowsManager implements IWindowsMainService { // Send to windows if (target) { const otherWindowsWithTarget = WindowsManager.WINDOWS.filter(w => w.id !== windowId && typeof w.openedWorkspacePath === 'string'); - const directTargetMatch = otherWindowsWithTarget.filter(w => isEqual(target, w.openedWorkspacePath)); - const parentTargetMatch = otherWindowsWithTarget.filter(w => isParent(target, w.openedWorkspacePath)); + const directTargetMatch = otherWindowsWithTarget.filter(w => isEqual(target, w.openedWorkspacePath, !platform.isLinux /* ignorecase */)); + const parentTargetMatch = otherWindowsWithTarget.filter(w => isParent(target, w.openedWorkspacePath, !platform.isLinux /* ignorecase */)); const targetWindow = directTargetMatch.length ? directTargetMatch[0] : parentTargetMatch[0]; // prefer direct match over parent match if (targetWindow) { @@ -317,7 +317,7 @@ export class WindowsManager implements IWindowsMainService { // Any non extension host window with same workspace else if (!win.isExtensionDevelopmentHost && !!win.openedWorkspacePath) { this.windowsState.openedFolders.forEach(o => { - if (isEqual(o.workspacePath, win.openedWorkspacePath)) { + if (isEqual(o.workspacePath, win.openedWorkspacePath, !platform.isLinux /* ignorecase */)) { o.uiState = state.uiState; } }); @@ -510,7 +510,7 @@ export class WindowsManager implements IWindowsMainService { // Open remaining ones allFoldersToOpen.forEach(folderToOpen => { - if (windowsOnWorkspacePath.some(win => isEqual(win.openedWorkspacePath, folderToOpen))) { + if (windowsOnWorkspacePath.some(win => isEqual(win.openedWorkspacePath, folderToOpen, !platform.isLinux /* ignorecase */))) { return; // ignore folders that are already open } @@ -684,7 +684,7 @@ export class WindowsManager implements IWindowsMainService { // Reload an existing extension development host window on the same path // We currently do not allow more than one extension development window // on the same extension path. - let res = WindowsManager.WINDOWS.filter(w => w.config && isEqual(w.config.extensionDevelopmentPath, openConfig.cli.extensionDevelopmentPath)); + let res = WindowsManager.WINDOWS.filter(w => w.config && isEqual(w.config.extensionDevelopmentPath, openConfig.cli.extensionDevelopmentPath, !platform.isLinux /* ignorecase */)); if (res && res.length === 1) { this.reload(res[0], openConfig.cli); res[0].focus(); // make sure it gets focus and is restored @@ -906,7 +906,7 @@ export class WindowsManager implements IWindowsMainService { // Known Folder - load from stored settings if any if (configuration.workspacePath) { - const stateForWorkspace = this.windowsState.openedFolders.filter(o => isEqual(o.workspacePath, configuration.workspacePath)).map(o => o.uiState); + const stateForWorkspace = this.windowsState.openedFolders.filter(o => isEqual(o.workspacePath, configuration.workspacePath, !platform.isLinux /* ignorecase */)).map(o => o.uiState); if (stateForWorkspace.length) { return stateForWorkspace[0]; } @@ -1103,22 +1103,22 @@ export class WindowsManager implements IWindowsMainService { const res = windowsToTest.filter(w => { // match on workspace - if (typeof w.openedWorkspacePath === 'string' && (isEqual(w.openedWorkspacePath, workspacePath))) { + if (typeof w.openedWorkspacePath === 'string' && (isEqual(w.openedWorkspacePath, workspacePath, !platform.isLinux /* ignorecase */))) { return true; } // match on file - if (typeof w.openedFilePath === 'string' && isEqual(w.openedFilePath, filePath)) { + if (typeof w.openedFilePath === 'string' && isEqual(w.openedFilePath, filePath, !platform.isLinux /* ignorecase */)) { return true; } // match on file path - if (typeof w.openedWorkspacePath === 'string' && filePath && isEqualOrParent(filePath, w.openedWorkspacePath)) { + if (typeof w.openedWorkspacePath === 'string' && filePath && isEqualOrParent(filePath, w.openedWorkspacePath, !platform.isLinux /* ignorecase */)) { return true; } // match on extension development path - if (typeof extensionDevelopmentPath === 'string' && w.extensionDevelopmentPath === extensionDevelopmentPath) { + if (typeof extensionDevelopmentPath === 'string' && isEqual(w.extensionDevelopmentPath, extensionDevelopmentPath, !platform.isLinux /* ignorecase */)) { return true; } diff --git a/src/vs/code/node/windowsUtils.ts b/src/vs/code/node/windowsUtils.ts index d4f9403534a..31a4f00b354 100644 --- a/src/vs/code/node/windowsUtils.ts +++ b/src/vs/code/node/windowsUtils.ts @@ -47,7 +47,7 @@ export function findBestWindowOrFolder({ win } function findBestWindow(windows: WINDOW[], filePath: string): WINDOW { - const containers = windows.filter(window => typeof window.openedWorkspacePath === 'string' && isEqualOrParent(filePath, window.openedWorkspacePath)); + const containers = windows.filter(window => typeof window.openedWorkspacePath === 'string' && isEqualOrParent(filePath, window.openedWorkspacePath, !platform.isLinux /* ignorecase */)); if (containers.length) { return containers.sort((a, b) => -(a.openedWorkspacePath.length - b.openedWorkspacePath.length))[0]; } diff --git a/src/vs/editor/browser/services/standaloneThemeServiceImpl.ts b/src/vs/editor/browser/services/standaloneThemeServiceImpl.ts index 74dcef4f239..e94e0472872 100644 --- a/src/vs/editor/browser/services/standaloneThemeServiceImpl.ts +++ b/src/vs/editor/browser/services/standaloneThemeServiceImpl.ts @@ -9,7 +9,7 @@ import { IStandaloneThemeService, BuiltinTheme, IStandaloneThemeData, IStandalon import { vs, vs_dark, hc_black } from 'vs/editor/common/standalone/themes'; import * as dom from 'vs/base/browser/dom'; import { TokenizationRegistry } from 'vs/editor/common/modes'; -import { Color } from "vs/base/common/color"; +import { Color } from 'vs/base/common/color'; import { Extensions, IColorRegistry, ColorIdentifier } from 'vs/platform/theme/common/colorRegistry'; import { Extensions as ThemingExtensions, IThemingRegistry, ICssStyleCollector } from 'vs/platform/theme/common/themeService'; import { Registry } from 'vs/platform/platform'; diff --git a/src/vs/editor/common/services/standaloneThemeService.ts b/src/vs/editor/common/services/standaloneThemeService.ts index 0c42429d357..1cd8f788130 100644 --- a/src/vs/editor/common/services/standaloneThemeService.ts +++ b/src/vs/editor/common/services/standaloneThemeService.ts @@ -6,7 +6,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { TokenTheme, ITokenThemeRule } from 'vs/editor/common/modes/supports/tokenization'; -import { ITheme, IThemeService } from "vs/platform/theme/common/themeService"; +import { ITheme, IThemeService } from 'vs/platform/theme/common/themeService'; export var IStandaloneThemeService = createDecorator('themeService'); diff --git a/src/vs/editor/common/standalone/themes.ts b/src/vs/editor/common/standalone/themes.ts index 6a79f511348..311617cea47 100644 --- a/src/vs/editor/common/standalone/themes.ts +++ b/src/vs/editor/common/standalone/themes.ts @@ -5,7 +5,7 @@ 'use strict'; -import { IStandaloneThemeData } from "vs/editor/common/services/standaloneThemeService"; +import { IStandaloneThemeData } from 'vs/editor/common/services/standaloneThemeService'; /* -------------------------------- Begin vs theme -------------------------------- */ export const vs: IStandaloneThemeData = { diff --git a/src/vs/editor/test/browser/standalone/simpleServices.test.ts b/src/vs/editor/test/browser/standalone/simpleServices.test.ts index 12755f6d097..14c53c99b5e 100644 --- a/src/vs/editor/test/browser/standalone/simpleServices.test.ts +++ b/src/vs/editor/test/browser/standalone/simpleServices.test.ts @@ -10,7 +10,7 @@ import { SimpleConfigurationService, SimpleMessageService, StandaloneKeybindingS import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { KeyCode } from 'vs/base/common/keyCodes'; -import { IKeyboardEvent } from "vs/platform/keybinding/common/keybinding"; +import { IKeyboardEvent } from 'vs/platform/keybinding/common/keybinding'; suite('StandaloneKeybindingService', () => { diff --git a/src/vs/platform/files/common/files.ts b/src/vs/platform/files/common/files.ts index dcf4115539a..731fe0ab7fd 100644 --- a/src/vs/platform/files/common/files.ts +++ b/src/vs/platform/files/common/files.ts @@ -12,7 +12,6 @@ import events = require('vs/base/common/events'); import { isLinux } from 'vs/base/common/platform'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import Event from 'vs/base/common/event'; -import { Schemas } from 'vs/base/common/network'; import { equalsIgnoreCase, beginsWithIgnoreCase } from 'vs/base/common/strings'; export const IFileService = createDecorator('fileService'); @@ -232,10 +231,10 @@ export class FileChangesEvent extends events.Event { // For deleted also return true when deleted folder is parent of target path if (type === FileChangeType.DELETED) { - return isEqualOrParent(resource.fsPath, change.resource.fsPath); + return isEqualOrParent(resource.fsPath, change.resource.fsPath, !isLinux /* ignorecase */); } - return isEqual(resource.fsPath, change.resource.fsPath); + return isEqual(resource.fsPath, change.resource.fsPath, !isLinux /* ignorecase */); }); } @@ -292,48 +291,20 @@ export class FileChangesEvent extends events.Event { } } -export function isEqual(resourceA: URI, resourceB: URI): boolean; -export function isEqual(pathA: string, pathB: string): boolean; -export function isEqual(resourceOrPathA: string | URI, resourceOrPathB: string | URI): boolean { - const identityEquals = (resourceOrPathA === resourceOrPathB); - if (identityEquals) { - return true; - } - - if (!resourceOrPathA || !resourceOrPathB) { - return false; - } - - // Compare by URI - if (typeof resourceOrPathA !== 'string') { - const resourceA = resourceOrPathA; - const resourceB = resourceOrPathB as URI; - - if (resourceA.scheme !== resourceB.scheme) { - return false; - } - - // File URIs compare by fsPath - if (resourceA.scheme === Schemas.file) { - return isEqual(resourceA.fsPath, resourceB.fsPath); - } - - // Non-file URIs compare by full string - return resourceA.toString() === resourceB.toString(); - } - - // Compare by Path - const pathA = resourceOrPathA; - const pathB = resourceOrPathB as string; - - if (isLinux) { +export function isEqual(pathA: string, pathB: string, ignoreCase?: boolean): boolean { + const identityEquals = (pathA === pathB); + if (!ignoreCase || identityEquals) { return identityEquals; } + if (!pathA || !pathB) { + return false; + } + return equalsIgnoreCase(pathA, pathB); } -export function isParent(path: string, candidate: string): boolean { +export function isParent(path: string, candidate: string, ignoreCase?: boolean): boolean { if (!path || !candidate || path === candidate) { return false; } @@ -346,14 +317,14 @@ export function isParent(path: string, candidate: string): boolean { candidate += paths.nativeSep; } - if (!isLinux) { + if (ignoreCase) { return beginsWithIgnoreCase(path, candidate); } return path.indexOf(candidate) === 0; } -export function isEqualOrParent(path: string, candidate: string): boolean { +export function isEqualOrParent(path: string, candidate: string, ignoreCase?: boolean): boolean { if (path === candidate) { return true; } @@ -366,7 +337,7 @@ export function isEqualOrParent(path: string, candidate: string): boolean { return false; } - if (!isLinux) { + if (ignoreCase) { const beginsWith = beginsWithIgnoreCase(path, candidate); if (!beginsWith) { return false; diff --git a/src/vs/platform/files/test/files.test.ts b/src/vs/platform/files/test/files.test.ts index 01f0313a521..6169607ad44 100644 --- a/src/vs/platform/files/test/files.test.ts +++ b/src/vs/platform/files/test/files.test.ts @@ -47,190 +47,144 @@ suite('Files', () => { assert.strictEqual(true, r1.gotDeleted()); }); - function testIsEqual(testMethod: (pA: string, pB: string) => boolean): void { + function testIsEqual(testMethod: (pA: string, pB: string, ignoreCase: boolean) => boolean): void { // corner cases - assert(testMethod('', '')); - assert(!testMethod(null, '')); - assert(!testMethod(void 0, '')); + assert(testMethod('', '', true)); + assert(!testMethod(null, '', true)); + assert(!testMethod(void 0, '', true)); // basics (string) - assert(testMethod('/', '/')); - assert(testMethod('/some', '/some')); - assert(testMethod('/some/path', '/some/path')); + assert(testMethod('/', '/', true)); + assert(testMethod('/some', '/some', true)); + assert(testMethod('/some/path', '/some/path', true)); - assert(testMethod('c:\\', 'c:\\')); - assert(testMethod('c:\\some', 'c:\\some')); - assert(testMethod('c:\\some\\path', 'c:\\some\\path')); + assert(testMethod('c:\\', 'c:\\', true)); + assert(testMethod('c:\\some', 'c:\\some', true)); + assert(testMethod('c:\\some\\path', 'c:\\some\\path', true)); - assert(testMethod('/someöäü/path', '/someöäü/path')); - assert(testMethod('c:\\someöäü\\path', 'c:\\someöäü\\path')); + assert(testMethod('/someöäü/path', '/someöäü/path', true)); + assert(testMethod('c:\\someöäü\\path', 'c:\\someöäü\\path', true)); - assert(!testMethod('/some/path', '/some/other/path')); - assert(!testMethod('c:\\some\\path', 'c:\\some\\other\\path')); - assert(!testMethod('c:\\some\\path', 'd:\\some\\path')); + assert(!testMethod('/some/path', '/some/other/path', true)); + assert(!testMethod('c:\\some\\path', 'c:\\some\\other\\path', true)); + assert(!testMethod('c:\\some\\path', 'd:\\some\\path', true)); - // case insensitive (unless isLinux) - if (isLinux) { - assert(!testMethod('/some/path', '/some/PATH')); - assert(!testMethod('/some/path', '/some/other/PATH')); - } else { - assert(testMethod('/some/path', '/some/PATH')); - assert(testMethod('/someöäü/path', '/someÖÄÜ/PATH')); - assert(testMethod('c:\\some\\path', 'c:\\some\\PATH')); - assert(testMethod('c:\\someöäü\\path', 'c:\\someÖÄÜ\\PATH')); - assert(testMethod('c:\\some\\path', 'C:\\some\\PATH')); - } + assert(testMethod('/some/path', '/some/PATH', true)); + assert(testMethod('/someöäü/path', '/someÖÄÜ/PATH', true)); + assert(testMethod('c:\\some\\path', 'c:\\some\\PATH', true)); + assert(testMethod('c:\\someöäü\\path', 'c:\\someÖÄÜ\\PATH', true)); + assert(testMethod('c:\\some\\path', 'C:\\some\\PATH', true)); } - test('isEqual', function () { + test('isEqual (ignoreCase)', function () { testIsEqual(isEqual); // basics (uris) - assert(isEqual(URI.file('/some/path'), URI.file('/some/path'))); - assert(isEqual(URI.file('c:\\some\\path'), URI.file('c:\\some\\path'))); + assert(isEqual(URI.file('/some/path').fsPath, URI.file('/some/path').fsPath, true)); + assert(isEqual(URI.file('c:\\some\\path').fsPath, URI.file('c:\\some\\path').fsPath, true)); - assert(isEqual(URI.file('/someöäü/path'), URI.file('/someöäü/path'))); - assert(isEqual(URI.file('c:\\someöäü\\path'), URI.file('c:\\someöäü\\path'))); + assert(isEqual(URI.file('/someöäü/path').fsPath, URI.file('/someöäü/path').fsPath, true)); + assert(isEqual(URI.file('c:\\someöäü\\path').fsPath, URI.file('c:\\someöäü\\path').fsPath, true)); - assert(!isEqual(URI.file('/some/path'), URI.file('/some/other/path'))); - assert(!isEqual(URI.file('c:\\some\\path'), URI.file('c:\\some\\other\\path'))); + assert(!isEqual(URI.file('/some/path').fsPath, URI.file('/some/other/path').fsPath, true)); + assert(!isEqual(URI.file('c:\\some\\path').fsPath, URI.file('c:\\some\\other\\path').fsPath, true)); - assert(isEqual(URI.parse('some://cool/uri'), URI.parse('some://cool/uri'))); - assert(!isEqual(URI.parse('some://cool/uri'), URI.parse('some://other/uri'))); - - // case insensitive (unless isLinux) - if (isLinux) { - assert(!isEqual(URI.file('/some/path'), URI.file('/some/PATH'))); - } else { - assert(isEqual(URI.file('/some/path'), URI.file('/some/PATH'))); - assert(isEqual(URI.file('/someöäü/path'), URI.file('/someÖÄÜ/PATH'))); - assert(isEqual(URI.file('c:\\some\\path'), URI.file('c:\\some\\PATH'))); - assert(isEqual(URI.file('c:\\someöäü\\path'), URI.file('c:\\someÖÄÜ\\PATH'))); - assert(isEqual(URI.file('c:\\some\\path'), URI.file('C:\\some\\PATH'))); - } + assert(isEqual(URI.file('/some/path').fsPath, URI.file('/some/PATH').fsPath, true)); + assert(isEqual(URI.file('/someöäü/path').fsPath, URI.file('/someÖÄÜ/PATH').fsPath, true)); + assert(isEqual(URI.file('c:\\some\\path').fsPath, URI.file('c:\\some\\PATH').fsPath, true)); + assert(isEqual(URI.file('c:\\someöäü\\path').fsPath, URI.file('c:\\someÖÄÜ\\PATH').fsPath, true)); + assert(isEqual(URI.file('c:\\some\\path').fsPath, URI.file('C:\\some\\PATH').fsPath, true)); }); - test('isParent', function () { + test('isParent (ignorecase)', function () { if (isWindows) { - assert(isParent('c:\\some\\path', 'c:\\')); - assert(isParent('c:\\some\\path', 'c:\\some')); - assert(isParent('c:\\some\\path', 'c:\\some\\')); - assert(isParent('c:\\someöäü\\path', 'c:\\someöäü')); - assert(isParent('c:\\someöäü\\path', 'c:\\someöäü\\')); - assert(isParent('c:\\foo\\bar\\test.ts', 'c:\\foo\\bar')); - assert(isParent('c:\\foo\\bar\\test.ts', 'c:\\foo\\bar\\')); + assert(isParent('c:\\some\\path', 'c:\\', true)); + assert(isParent('c:\\some\\path', 'c:\\some', true)); + assert(isParent('c:\\some\\path', 'c:\\some\\', true)); + assert(isParent('c:\\someöäü\\path', 'c:\\someöäü', true)); + assert(isParent('c:\\someöäü\\path', 'c:\\someöäü\\', true)); + assert(isParent('c:\\foo\\bar\\test.ts', 'c:\\foo\\bar', true)); + assert(isParent('c:\\foo\\bar\\test.ts', 'c:\\foo\\bar\\', true)); - assert(isParent('c:\\some\\path', 'C:\\')); - assert(isParent('c:\\some\\path', 'c:\\SOME')); - assert(isParent('c:\\some\\path', 'c:\\SOME\\')); + assert(isParent('c:\\some\\path', 'C:\\', true)); + assert(isParent('c:\\some\\path', 'c:\\SOME', true)); + assert(isParent('c:\\some\\path', 'c:\\SOME\\', true)); - assert(!isParent('c:\\some\\path', 'd:\\')); - assert(!isParent('c:\\some\\path', 'c:\\some\\path')); - assert(!isParent('c:\\some\\path', 'd:\\some\\path')); - assert(!isParent('c:\\foo\\bar\\test.ts', 'c:\\foo\\barr')); - assert(!isParent('c:\\foo\\bar\\test.ts', 'c:\\foo\\bar\\test')); + assert(!isParent('c:\\some\\path', 'd:\\', true)); + assert(!isParent('c:\\some\\path', 'c:\\some\\path', true)); + assert(!isParent('c:\\some\\path', 'd:\\some\\path', true)); + assert(!isParent('c:\\foo\\bar\\test.ts', 'c:\\foo\\barr', true)); + assert(!isParent('c:\\foo\\bar\\test.ts', 'c:\\foo\\bar\\test', true)); } - if (isMacintosh) { - assert(isParent('/some/path', '/')); - assert(isParent('/some/path', '/some')); - assert(isParent('/some/path', '/some/')); - assert(isParent('/someöäü/path', '/someöäü')); - assert(isParent('/someöäü/path', '/someöäü/')); - assert(isParent('/foo/bar/test.ts', '/foo/bar')); - assert(isParent('/foo/bar/test.ts', '/foo/bar/')); + if (isMacintosh || isLinux) { + assert(isParent('/some/path', '/', true)); + assert(isParent('/some/path', '/some', true)); + assert(isParent('/some/path', '/some/', true)); + assert(isParent('/someöäü/path', '/someöäü', true)); + assert(isParent('/someöäü/path', '/someöäü/', true)); + assert(isParent('/foo/bar/test.ts', '/foo/bar', true)); + assert(isParent('/foo/bar/test.ts', '/foo/bar/', true)); - assert(isParent('/some/path', '/SOME')); - assert(isParent('/some/path', '/SOME/')); - assert(isParent('/someöäü/path', '/SOMEÖÄÜ')); - assert(isParent('/someöäü/path', '/SOMEÖÄÜ/')); + assert(isParent('/some/path', '/SOME', true)); + assert(isParent('/some/path', '/SOME/', true)); + assert(isParent('/someöäü/path', '/SOMEÖÄÜ', true)); + assert(isParent('/someöäü/path', '/SOMEÖÄÜ/', true)); - assert(!isParent('/some/path', '/some/path')); - assert(!isParent('/foo/bar/test.ts', '/foo/barr')); - assert(!isParent('/foo/bar/test.ts', '/foo/bar/test')); - } - - if (isLinux) { - assert(isParent('/some/path', '/')); - assert(isParent('/some/path', '/some')); - assert(isParent('/some/path', '/some/')); - assert(isParent('/someöäü/path', '/someöäü')); - assert(isParent('/someöäü/path', '/someöäü/')); - assert(isParent('/foo/bar/test.ts', '/foo/bar')); - assert(isParent('/foo/bar/test.ts', '/foo/bar/')); - - assert(!isParent('/some/path', '/SOME')); - - assert(!isParent('/some/path', '/some/path')); - assert(!isParent('/foo/bar/test.ts', '/foo/barr')); - assert(!isParent('/foo/bar/test.ts', '/foo/bar/test')); + assert(!isParent('/some/path', '/some/path', true)); + assert(!isParent('/foo/bar/test.ts', '/foo/barr', true)); + assert(!isParent('/foo/bar/test.ts', '/foo/bar/test', true)); } }); - test('isEqualOrParent', function () { + test('isEqualOrParent (ignorecase)', function () { // same assertions apply as with isEqual() testIsEqual(isEqualOrParent); if (isWindows) { - assert(isEqualOrParent('c:\\some\\path', 'c:\\')); - assert(isEqualOrParent('c:\\some\\path', 'c:\\some')); - assert(isEqualOrParent('c:\\some\\path', 'c:\\some\\')); - assert(isEqualOrParent('c:\\someöäü\\path', 'c:\\someöäü')); - assert(isEqualOrParent('c:\\someöäü\\path', 'c:\\someöäü\\')); - assert(isEqualOrParent('c:\\foo\\bar\\test.ts', 'c:\\foo\\bar')); - assert(isEqualOrParent('c:\\foo\\bar\\test.ts', 'c:\\foo\\bar\\')); - assert(isEqualOrParent('c:\\some\\path', 'c:\\some\\path')); - assert(isEqualOrParent('c:\\foo\\bar\\test.ts', 'c:\\foo\\bar\\test.ts')); + assert(isEqualOrParent('c:\\some\\path', 'c:\\', true)); + assert(isEqualOrParent('c:\\some\\path', 'c:\\some', true)); + assert(isEqualOrParent('c:\\some\\path', 'c:\\some\\', true)); + assert(isEqualOrParent('c:\\someöäü\\path', 'c:\\someöäü', true)); + assert(isEqualOrParent('c:\\someöäü\\path', 'c:\\someöäü\\', true)); + assert(isEqualOrParent('c:\\foo\\bar\\test.ts', 'c:\\foo\\bar', true)); + assert(isEqualOrParent('c:\\foo\\bar\\test.ts', 'c:\\foo\\bar\\', true)); + assert(isEqualOrParent('c:\\some\\path', 'c:\\some\\path', true)); + assert(isEqualOrParent('c:\\foo\\bar\\test.ts', 'c:\\foo\\bar\\test.ts', true)); - assert(isEqualOrParent('c:\\some\\path', 'C:\\')); - assert(isEqualOrParent('c:\\some\\path', 'c:\\SOME')); - assert(isEqualOrParent('c:\\some\\path', 'c:\\SOME\\')); + assert(isEqualOrParent('c:\\some\\path', 'C:\\', true)); + assert(isEqualOrParent('c:\\some\\path', 'c:\\SOME', true)); + assert(isEqualOrParent('c:\\some\\path', 'c:\\SOME\\', true)); - assert(!isEqualOrParent('c:\\some\\path', 'd:\\')); - assert(!isEqualOrParent('c:\\some\\path', 'd:\\some\\path')); - assert(!isEqualOrParent('c:\\foo\\bar\\test.ts', 'c:\\foo\\barr')); - assert(!isEqualOrParent('c:\\foo\\bar\\test.ts', 'c:\\foo\\bar\\test')); - assert(!isEqualOrParent('c:\\foo\\bar\\test.ts', 'c:\\foo\\bar\\test.')); - assert(!isEqualOrParent('c:\\foo\\bar\\test.ts', 'c:\\foo\\BAR\\test.')); + assert(!isEqualOrParent('c:\\some\\path', 'd:\\', true)); + assert(!isEqualOrParent('c:\\some\\path', 'd:\\some\\path', true)); + assert(!isEqualOrParent('c:\\foo\\bar\\test.ts', 'c:\\foo\\barr', true)); + assert(!isEqualOrParent('c:\\foo\\bar\\test.ts', 'c:\\foo\\bar\\test', true)); + assert(!isEqualOrParent('c:\\foo\\bar\\test.ts', 'c:\\foo\\bar\\test.', true)); + assert(!isEqualOrParent('c:\\foo\\bar\\test.ts', 'c:\\foo\\BAR\\test.', true)); } - if (isMacintosh) { - assert(isEqualOrParent('/some/path', '/')); - assert(isEqualOrParent('/some/path', '/some')); - assert(isEqualOrParent('/some/path', '/some/')); - assert(isEqualOrParent('/someöäü/path', '/someöäü')); - assert(isEqualOrParent('/someöäü/path', '/someöäü/')); - assert(isEqualOrParent('/foo/bar/test.ts', '/foo/bar')); - assert(isEqualOrParent('/foo/bar/test.ts', '/foo/bar/')); - assert(isEqualOrParent('/some/path', '/some/path')); + if (isMacintosh || isLinux) { + assert(isEqualOrParent('/some/path', '/', true)); + assert(isEqualOrParent('/some/path', '/some', true)); + assert(isEqualOrParent('/some/path', '/some/', true)); + assert(isEqualOrParent('/someöäü/path', '/someöäü', true)); + assert(isEqualOrParent('/someöäü/path', '/someöäü/', true)); + assert(isEqualOrParent('/foo/bar/test.ts', '/foo/bar', true)); + assert(isEqualOrParent('/foo/bar/test.ts', '/foo/bar/', true)); + assert(isEqualOrParent('/some/path', '/some/path', true)); - assert(isEqualOrParent('/some/path', '/SOME')); - assert(isEqualOrParent('/some/path', '/SOME/')); - assert(isEqualOrParent('/someöäü/path', '/SOMEÖÄÜ')); - assert(isEqualOrParent('/someöäü/path', '/SOMEÖÄÜ/')); + assert(isEqualOrParent('/some/path', '/SOME', true)); + assert(isEqualOrParent('/some/path', '/SOME/', true)); + assert(isEqualOrParent('/someöäü/path', '/SOMEÖÄÜ', true)); + assert(isEqualOrParent('/someöäü/path', '/SOMEÖÄÜ/', true)); - assert(!isEqualOrParent('/foo/bar/test.ts', '/foo/barr')); - assert(!isEqualOrParent('/foo/bar/test.ts', '/foo/bar/test')); - assert(!isEqualOrParent('foo/bar/test.ts', 'foo/bar/test.')); - assert(!isEqualOrParent('foo/bar/test.ts', 'foo/BAR/test.')); - } - - if (isLinux) { - assert(isEqualOrParent('/some/path', '/')); - assert(isEqualOrParent('/some/path', '/some')); - assert(isEqualOrParent('/some/path', '/some/')); - assert(isEqualOrParent('/someöäü/path', '/someöäü')); - assert(isEqualOrParent('/someöäü/path', '/someöäü/')); - assert(isEqualOrParent('/foo/bar/test.ts', '/foo/bar')); - assert(isEqualOrParent('/foo/bar/test.ts', '/foo/bar/')); - assert(isEqualOrParent('/some/path', '/some/path')); - - assert(!isEqualOrParent('/some/path', '/SOME')); - - assert(!isEqualOrParent('/foo/bar/test.ts', '/foo/barr')); - assert(!isEqualOrParent('/foo/bar/test.ts', '/foo/bar/test')); + assert(!isEqualOrParent('/foo/bar/test.ts', '/foo/barr', true)); + assert(!isEqualOrParent('/foo/bar/test.ts', '/foo/bar/test', true)); + assert(!isEqualOrParent('foo/bar/test.ts', 'foo/bar/test.', true)); + assert(!isEqualOrParent('foo/bar/test.ts', 'foo/BAR/test.', true)); } }); diff --git a/src/vs/platform/workspace/common/workspace.ts b/src/vs/platform/workspace/common/workspace.ts index 611e8a42f52..1218ddd4da8 100644 --- a/src/vs/platform/workspace/common/workspace.ts +++ b/src/vs/platform/workspace/common/workspace.ts @@ -8,6 +8,7 @@ import URI from 'vs/base/common/uri'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import paths = require('vs/base/common/paths'); import { isEqualOrParent } from 'vs/platform/files/common/files'; +import { isLinux } from 'vs/base/common/platform'; export const IWorkspaceContextService = createDecorator('contextService'); @@ -84,7 +85,7 @@ export class WorkspaceContextService implements IWorkspaceContextService { public isInsideWorkspace(resource: URI): boolean { if (resource && this.workspace) { - return isEqualOrParent(resource.fsPath, this.workspace.resource.fsPath); + return isEqualOrParent(resource.fsPath, this.workspace.resource.fsPath, !isLinux /* ignorecase */); } return false; diff --git a/src/vs/workbench/browser/parts/editor/editorStatus.ts b/src/vs/workbench/browser/parts/editor/editorStatus.ts index 9e22888aa24..b2b95a85d73 100644 --- a/src/vs/workbench/browser/parts/editor/editorStatus.ts +++ b/src/vs/workbench/browser/parts/editor/editorStatus.ts @@ -34,7 +34,7 @@ import { IEditor as IBaseEditor, IEditorInput } from 'vs/platform/editor/common/ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IQuickOpenService, IPickOpenEntry, IFilePickOpenEntry } from 'vs/platform/quickOpen/common/quickOpen'; import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration'; -import { IFilesConfiguration, SUPPORTED_ENCODINGS, isEqual } from 'vs/platform/files/common/files'; +import { IFilesConfiguration, SUPPORTED_ENCODINGS } from 'vs/platform/files/common/files'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IModeService } from 'vs/editor/common/services/modeService'; import { IModelService } from 'vs/editor/common/services/modelService'; @@ -649,7 +649,7 @@ export class EditorStatus implements IStatusbarItem { const activeEditor = this.editorService.getActiveEditor(); if (activeEditor) { const activeResource = toResource(activeEditor.input, { supportSideBySide: true, filter: ['file', 'untitled'] }); - if (isEqual(activeResource, resource)) { + if (activeResource.toString() === resource.toString()) { return this.onEncodingChange(activeEditor); // only update if the encoding changed for the active resource } } diff --git a/src/vs/workbench/common/editor/editorStacksModel.ts b/src/vs/workbench/common/editor/editorStacksModel.ts index 2b45a49546f..cf35c2c5f9a 100644 --- a/src/vs/workbench/common/editor/editorStacksModel.ts +++ b/src/vs/workbench/common/editor/editorStacksModel.ts @@ -15,7 +15,6 @@ import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle'; import { dispose, IDisposable } from 'vs/base/common/lifecycle'; import { Registry } from 'vs/platform/platform'; import { Position, Direction } from 'vs/platform/editor/common/editor'; -import { isEqual } from 'vs/platform/files/common/files'; import { ResourceMap } from 'vs/base/common/map'; export interface GroupEvent extends IGroupEvent { @@ -199,7 +198,7 @@ export class EditorGroup implements IEditorGroup { for (let i = 0; i < this.editors.length; i++) { const editor = this.editors[i]; const editorResource = toResource(editor, { supportSideBySide: true }); - if (isEqual(editorResource, resource)) { + if (editorResource.toString() === resource.toString()) { return editor; } } diff --git a/src/vs/workbench/electron-browser/window.ts b/src/vs/workbench/electron-browser/window.ts index db7b70c5409..bfbb4f990c2 100644 --- a/src/vs/workbench/electron-browser/window.ts +++ b/src/vs/workbench/electron-browser/window.ts @@ -49,7 +49,7 @@ import { IExtensionService } from 'vs/platform/extensions/common/extensions'; import { Themable, EDITOR_DRAG_AND_DROP_BACKGROUND } from 'vs/workbench/common/theme'; import { remote, ipcRenderer as ipc, webFrame } from 'electron'; -import { highContrastOutline } from "vs/platform/theme/common/colorRegistry"; +import { highContrastOutline } from 'vs/platform/theme/common/colorRegistry'; const dialog = remote.dialog; diff --git a/src/vs/workbench/parts/files/browser/fileActions.ts b/src/vs/workbench/parts/files/browser/fileActions.ts index 98c841db700..b6eb5184b5f 100644 --- a/src/vs/workbench/parts/files/browser/fileActions.ts +++ b/src/vs/workbench/parts/files/browser/fileActions.ts @@ -288,7 +288,7 @@ class RenameFileAction extends BaseRenameAction { public runAction(newName: string): TPromise { let isDirtyCaseChange = false; - const dirty = this.textFileService.getDirty().filter(d => isEqualOrParent(d.fsPath, this.element.resource.fsPath)); + const dirty = this.textFileService.getDirty().filter(d => isEqualOrParent(d.fsPath, this.element.resource.fsPath, !isLinux /* ignorecase */)); const dirtyRenamed = dirty.map(d => { const targetPath = paths.join(this.element.parent.resource.fsPath, newName); let renamed: URI; @@ -702,7 +702,7 @@ export class BaseDeleteFileAction extends BaseFileAction { // Handle dirty let revertPromise: TPromise = TPromise.as(null); - const dirty = this.textFileService.getDirty().filter(d => isEqualOrParent(d.fsPath, this.element.resource.fsPath)); + const dirty = this.textFileService.getDirty().filter(d => isEqualOrParent(d.fsPath, this.element.resource.fsPath, !isLinux /* ignorecase */)); if (dirty.length) { let message: string; if (this.element.isDirectory) { @@ -994,7 +994,7 @@ export class PasteFileAction extends BaseFileAction { } // Check if target is ancestor of pasted folder - if (!isEqual(this.element.resource.fsPath, fileToCopy.resource.fsPath) && isEqualOrParent(this.element.resource.fsPath, fileToCopy.resource.fsPath)) { + if (!isEqual(this.element.resource.fsPath, fileToCopy.resource.fsPath) && isEqualOrParent(this.element.resource.fsPath, fileToCopy.resource.fsPath, !isLinux /* ignorecase */)) { return false; } diff --git a/src/vs/workbench/parts/files/browser/views/explorerView.ts b/src/vs/workbench/parts/files/browser/views/explorerView.ts index dc2cbcaa081..457e1a4c214 100644 --- a/src/vs/workbench/parts/files/browser/views/explorerView.ts +++ b/src/vs/workbench/parts/files/browser/views/explorerView.ts @@ -41,6 +41,7 @@ import { IMessageService, Severity } from 'vs/platform/message/common/message'; import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey'; import { ResourceContextKey } from 'vs/workbench/common/resourceContextKey'; import { IWorkbenchThemeService, IFileIconTheme } from 'vs/workbench/services/themes/common/themeService'; +import { isLinux } from 'vs/base/common/platform'; export class ExplorerView extends CollapsibleViewletView { @@ -734,7 +735,7 @@ export class ExplorerView extends CollapsibleViewletView { // Drop those path which are parents of the current one for (let i = resolvedDirectories.length - 1; i >= 0; i--) { const resource = resolvedDirectories[i]; - if (isEqualOrParent(stat.resource.fsPath, resource.fsPath)) { + if (isEqualOrParent(stat.resource.fsPath, resource.fsPath, !isLinux /* ignorecase */)) { resolvedDirectories.splice(i); } } diff --git a/src/vs/workbench/parts/files/browser/views/explorerViewer.ts b/src/vs/workbench/parts/files/browser/views/explorerViewer.ts index a7ef92c1023..af9ef658fcd 100644 --- a/src/vs/workbench/parts/files/browser/views/explorerViewer.ts +++ b/src/vs/workbench/parts/files/browser/views/explorerViewer.ts @@ -19,7 +19,7 @@ import { IAction, ActionRunner as BaseActionRunner, IActionRunner } from 'vs/bas import comparers = require('vs/base/common/comparers'); import { InputBox } from 'vs/base/browser/ui/inputbox/inputBox'; import { $, Builder } from 'vs/base/browser/builder'; -import { isMacintosh } from 'vs/base/common/platform'; +import { isMacintosh, isLinux } from 'vs/base/common/platform'; import glob = require('vs/base/common/glob'); import { FileLabel, IFileLabelOptions } from 'vs/workbench/browser/labels'; import { IDisposable } from 'vs/base/common/lifecycle'; @@ -697,7 +697,7 @@ export class FileDragAndDrop implements IDragAndDrop { return true; // Can not move a file to the same parent unless we copy } - if (isEqualOrParent(target.resource.fsPath, source.resource.fsPath)) { + if (isEqualOrParent(target.resource.fsPath, source.resource.fsPath, !isLinux /* ignorecase */)) { return true; // Can not move a parent folder into one of its children } @@ -759,7 +759,7 @@ export class FileDragAndDrop implements IDragAndDrop { }; // 1. check for dirty files that are being moved and backup to new target - const dirty = this.textFileService.getDirty().filter(d => isEqualOrParent(d.fsPath, source.resource.fsPath)); + const dirty = this.textFileService.getDirty().filter(d => isEqualOrParent(d.fsPath, source.resource.fsPath, !isLinux /* ignorecase */)); return TPromise.join(dirty.map(d => { let moved: URI; @@ -802,7 +802,7 @@ export class FileDragAndDrop implements IDragAndDrop { // Move with overwrite if the user confirms if (this.messageService.confirm(confirm)) { - const targetDirty = this.textFileService.getDirty().filter(d => isEqualOrParent(d.fsPath, targetResource.fsPath)); + const targetDirty = this.textFileService.getDirty().filter(d => isEqualOrParent(d.fsPath, targetResource.fsPath, !isLinux /* ignorecase */)); // Make sure to revert all dirty in target first to be able to overwrite properly return this.textFileService.revertAll(targetDirty, { soft: true /* do not attempt to load content from disk */ }).then(() => { diff --git a/src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts b/src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts index 30038c6973d..b8d8a123b0f 100644 --- a/src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts +++ b/src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts @@ -22,6 +22,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { distinct } from 'vs/base/common/arrays'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; +import { isLinux } from 'vs/base/common/platform'; export class FileEditorTracker implements IWorkbenchContribution { private stacks: IEditorStacksModel; @@ -114,7 +115,7 @@ export class FileEditorTracker implements IWorkbenchContribution { // Do NOT close any opened editor that matches the resource path (either equal or being parent) of the // resource we move to (movedTo). Otherwise we would close a resource that has been renamed to the same // path but different casing. - if (movedTo && isEqualOrParent(resource.fsPath, movedTo.fsPath) && resource.fsPath.indexOf(movedTo.fsPath) === 0) { + if (movedTo && isEqualOrParent(resource.fsPath, movedTo.fsPath, !isLinux /* ignorecase */) && resource.fsPath.indexOf(movedTo.fsPath) === 0) { return; } @@ -122,7 +123,7 @@ export class FileEditorTracker implements IWorkbenchContribution { if (arg1 instanceof FileChangesEvent) { matches = arg1.contains(resource, FileChangeType.DELETED); } else { - matches = isEqualOrParent(resource.fsPath, arg1.fsPath); + matches = isEqualOrParent(resource.fsPath, arg1.fsPath, !isLinux /* ignorecase */); } if (!matches) { @@ -194,7 +195,7 @@ export class FileEditorTracker implements IWorkbenchContribution { const resource = input.getResource(); // Update Editor if file (or any parent of the input) got renamed or moved - if (isEqualOrParent(resource.fsPath, oldResource.fsPath)) { + if (isEqualOrParent(resource.fsPath, oldResource.fsPath, !isLinux /* ignorecase */)) { let reopenFileResource: URI; if (oldResource.toString() === resource.toString()) { reopenFileResource = newResource; // file got moved diff --git a/src/vs/workbench/parts/files/common/explorerViewModel.ts b/src/vs/workbench/parts/files/common/explorerViewModel.ts index 33066d5f6e6..df308c44db1 100644 --- a/src/vs/workbench/parts/files/common/explorerViewModel.ts +++ b/src/vs/workbench/parts/files/common/explorerViewModel.ts @@ -12,6 +12,7 @@ import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorIn import { IEditorInput } from 'vs/platform/editor/common/editor'; import { IEditorGroup, toResource } from 'vs/workbench/common/editor'; import { ResourceMap } from 'vs/base/common/map'; +import { isLinux } from 'vs/base/common/platform'; export enum StatType { FILE, @@ -61,7 +62,7 @@ export class FileStat implements IFileStat { // the folder is fully resolved if either it has a list of children or the client requested this by using the resolveTo // array of resource path to resolve. stat.isDirectoryResolved = !!raw.children || (!!resolveTo && resolveTo.some((r) => { - return isEqualOrParent(r.fsPath, stat.resource.fsPath); + return isEqualOrParent(r.fsPath, stat.resource.fsPath, !isLinux /* ignorecase */); })); // Recurse into children @@ -241,7 +242,7 @@ export class FileStat implements IFileStat { public find(resource: URI): FileStat { // Return if path found - if (isEqual(resource.fsPath, this.resource.fsPath)) { + if (isEqual(resource.fsPath, this.resource.fsPath, !isLinux /* ignorecase */)) { return this; } @@ -253,11 +254,11 @@ export class FileStat implements IFileStat { for (let i = 0; i < this.children.length; i++) { const child = this.children[i]; - if (isEqual(resource.fsPath, child.resource.fsPath)) { + if (isEqual(resource.fsPath, child.resource.fsPath, !isLinux /* ignorecase */)) { return child; } - if (child.isDirectory && isParent(resource.fsPath, child.resource.fsPath)) { + if (child.isDirectory && isParent(resource.fsPath, child.resource.fsPath, !isLinux /* ignorecase */)) { return child.find(resource); } } diff --git a/src/vs/workbench/parts/files/test/browser/fileEditorInput.test.ts b/src/vs/workbench/parts/files/test/browser/fileEditorInput.test.ts index c878e02bb98..e4e42670c14 100644 --- a/src/vs/workbench/parts/files/test/browser/fileEditorInput.test.ts +++ b/src/vs/workbench/parts/files/test/browser/fileEditorInput.test.ts @@ -16,7 +16,6 @@ import { ITextFileService } from 'vs/workbench/services/textfile/common/textfile import { FileOperationResult, IFileOperationResult } from 'vs/platform/files/common/files'; import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel'; import { Verbosity } from 'vs/platform/editor/common/editor'; -import { isLinux } from 'vs/base/common/platform'; function toResource(path) { return URI.file(join('C:\\', new Buffer(this.test.fullTitle()).toString('base64'), path)); @@ -115,11 +114,7 @@ suite('Files - FileEditorInput', () => { assert.strictEqual(input1.matches(input2), true); assert.strictEqual(input1.matches(input3), false); - if (isLinux) { - assert.strictEqual(input1.matches(input2Upper), false); - } else { - assert.strictEqual(input1.matches(input2Upper), true); - } + assert.strictEqual(input1.matches(input2Upper), false); }); test('getEncoding/setEncoding', function (done) { diff --git a/src/vs/workbench/parts/git/browser/views/changes/changesView.ts b/src/vs/workbench/parts/git/browser/views/changes/changesView.ts index 7be73c477ce..48f3037f246 100644 --- a/src/vs/workbench/parts/git/browser/views/changes/changesView.ts +++ b/src/vs/workbench/parts/git/browser/views/changes/changesView.ts @@ -453,12 +453,12 @@ export class ChangesView extends EventEmitter.EventEmitter implements GitView.IV const resource = WorkbenchEditorCommon.toResource(input, { filter: 'file' }); if (resource) { const workspaceRoot = this.contextService.getWorkspace().resource.fsPath; - if (!workspaceRoot || !isEqualOrParent(resource.fsPath, workspaceRoot)) { + if (!workspaceRoot || !isEqualOrParent(resource.fsPath, workspaceRoot, !Platform.isLinux /* ignorecase */)) { return null; // out of workspace not yet supported } const repositoryRoot = this.gitService.getModel().getRepositoryRoot(); - if (!repositoryRoot || !isEqualOrParent(resource.fsPath, repositoryRoot)) { + if (!repositoryRoot || !isEqualOrParent(resource.fsPath, repositoryRoot, !Platform.isLinux /* ignorecase */)) { return null; // out of repository not supported } diff --git a/src/vs/workbench/parts/markers/browser/markersPanel.ts b/src/vs/workbench/parts/markers/browser/markersPanel.ts index eae0551781f..ba408f9a445 100644 --- a/src/vs/workbench/parts/markers/browser/markersPanel.ts +++ b/src/vs/workbench/parts/markers/browser/markersPanel.ts @@ -247,7 +247,7 @@ export class MarkersPanel extends Panel { if (resourceForCurrentActiveFile) { return false; } - return changedResources.some(r => isEqual(r, this.currentActiveFile)); + return changedResources.some(r => r.toString() === this.currentActiveFile.toString()); } private onEditorsChanged(): void { @@ -334,7 +334,7 @@ export class MarkersPanel extends Panel { private getResourceForCurrentActiveFile(): Resource { if (this.currentActiveFile) { let resources = this.markersModel.filteredResources.filter((resource): boolean => { - return isEqual(this.currentActiveFile, resource.uri); + return this.currentActiveFile.toString() === resource.uri.toString(); }); return resources.length > 0 ? resources[0] : null; } diff --git a/src/vs/workbench/parts/search/browser/replaceService.ts b/src/vs/workbench/parts/search/browser/replaceService.ts index 33161e86911..d9e04d6684a 100644 --- a/src/vs/workbench/parts/search/browser/replaceService.ts +++ b/src/vs/workbench/parts/search/browser/replaceService.ts @@ -23,7 +23,7 @@ import { ITextModelResolverService, ITextModelContentProvider } from 'vs/editor/ import { IWorkbenchContribution } from 'vs/workbench/common/contributions'; import { IModel } from 'vs/editor/common/editorCommon'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { IFileService, isEqual } from 'vs/platform/files/common/files'; +import { IFileService } from 'vs/platform/files/common/files'; const REPLACE_PREVIEW = 'replacePreview'; @@ -69,7 +69,7 @@ class ReplacePreviewModel extends Disposable { resolve(replacePreviewUri: URI): TPromise { const fileResource = toFileResource(replacePreviewUri); - const fileMatch = this.searchWorkbenchService.searchModel.searchResult.matches().filter(match => isEqual(match.resource(), fileResource))[0]; + const fileMatch = this.searchWorkbenchService.searchModel.searchResult.matches().filter(match => match.resource().toString() === fileResource.toString())[0]; return this.textModelResolverService.createModelReference(fileResource).then(ref => { ref = this._register(ref); const sourceModel = ref.object.textEditorModel; diff --git a/src/vs/workbench/parts/search/common/searchModel.ts b/src/vs/workbench/parts/search/common/searchModel.ts index e4e5adb3679..6e954f6c80b 100644 --- a/src/vs/workbench/parts/search/common/searchModel.ts +++ b/src/vs/workbench/parts/search/common/searchModel.ts @@ -24,7 +24,6 @@ import { IModelService } from 'vs/editor/common/services/modelService'; import { IReplaceService } from 'vs/workbench/parts/search/common/replace'; import { IProgressRunner } from 'vs/platform/progress/common/progress'; import { RangeHighlightDecorations } from 'vs/workbench/common/editor/rangeDecorations'; -import { isEqual } from 'vs/platform/files/common/files'; export class Match { @@ -150,7 +149,7 @@ export class FileMatch extends Disposable { private registerListeners(): void { this._register(this.modelService.onModelAdded((model: IModel) => { - if (isEqual(model.uri, this._resource)) { + if (model.uri.toString() === this._resource.toString()) { this.bindModel(model); } })); diff --git a/src/vs/workbench/parts/search/test/browser/searchActions.test.ts b/src/vs/workbench/parts/search/test/browser/searchActions.test.ts index 81125067155..e9bd0455676 100644 --- a/src/vs/workbench/parts/search/test/browser/searchActions.test.ts +++ b/src/vs/workbench/parts/search/test/browser/searchActions.test.ts @@ -19,7 +19,7 @@ import { Tree } from 'vs/base/parts/tree/browser/treeImpl'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayoutResolvedKeybinding'; import { OS } from 'vs/base/common/platform'; -import { Keybinding } from "vs/base/common/keyCodes"; +import { Keybinding } from 'vs/base/common/keyCodes'; suite('Search Actions', () => { diff --git a/src/vs/workbench/services/files/node/fileService.ts b/src/vs/workbench/services/files/node/fileService.ts index b00931d927e..29a6950db56 100644 --- a/src/vs/workbench/services/files/node/fileService.ts +++ b/src/vs/workbench/services/files/node/fileService.ts @@ -23,7 +23,7 @@ import extfs = require('vs/base/node/extfs'); import { nfcall, Limiter, ThrottledDelayer } from 'vs/base/common/async'; import uri from 'vs/base/common/uri'; import nls = require('vs/nls'); -import { isWindows } from 'vs/base/common/platform'; +import { isWindows, isLinux } from 'vs/base/common/platform'; import { dispose, IDisposable, toDisposable } from 'vs/base/common/lifecycle'; import pfs = require('vs/base/node/pfs'); @@ -433,7 +433,7 @@ export class FileService implements IFileService { // 2.) make sure target is deleted before we move/copy unless this is a case rename of the same file let deleteTargetPromise = TPromise.as(null); if (exists && !isCaseRename) { - if (isEqualOrParent(sourcePath, targetPath)) { + if (isEqualOrParent(sourcePath, targetPath, !isLinux /* ignorecase */)) { return TPromise.wrapError(nls.localize('unableToMoveCopyError', "Unable to move/copy. File would replace folder it is contained in.")); // catch this corner case! } @@ -898,7 +898,7 @@ export class StatResolver { let resolveFolderChildren = false; if (files.length === 1 && resolveSingleChildDescendants) { resolveFolderChildren = true; - } else if (childCount > 0 && absoluteTargetPaths && absoluteTargetPaths.some(targetPath => isEqualOrParent(targetPath, fileResource.fsPath))) { + } else if (childCount > 0 && absoluteTargetPaths && absoluteTargetPaths.some(targetPath => isEqualOrParent(targetPath, fileResource.fsPath, !isLinux /* ignorecase */))) { resolveFolderChildren = true; } diff --git a/src/vs/workbench/services/files/node/watcher/common.ts b/src/vs/workbench/services/files/node/watcher/common.ts index 5b821565616..aa0559b3e77 100644 --- a/src/vs/workbench/services/files/node/watcher/common.ts +++ b/src/vs/workbench/services/files/node/watcher/common.ts @@ -7,6 +7,7 @@ import uri from 'vs/base/common/uri'; import { FileChangeType, FileChangesEvent, isParent } from 'vs/platform/files/common/files'; +import { isLinux } from 'vs/base/common/platform'; export interface IRawFileChange { type: FileChangeType; @@ -105,7 +106,7 @@ class EventNormalizer { }).sort((e1, e2) => { return e1.path.length - e2.path.length; // shortest path first }).filter(e => { - if (deletedPaths.some(d => isParent(e.path, d))) { + if (deletedPaths.some(d => isParent(e.path, d, !isLinux /* ignorecase */))) { return false; // DELETE is ignored if parent is deleted already } diff --git a/src/vs/workbench/services/textfile/test/textFileEditorModelManager.test.ts b/src/vs/workbench/services/textfile/test/textFileEditorModelManager.test.ts index 9415699370a..68dbda18efc 100644 --- a/src/vs/workbench/services/textfile/test/textFileEditorModelManager.test.ts +++ b/src/vs/workbench/services/textfile/test/textFileEditorModelManager.test.ts @@ -17,7 +17,6 @@ import { IEditorGroupService } from 'vs/workbench/services/group/common/groupSer import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel'; import { IFileService, FileChangesEvent, FileChangeType } from 'vs/platform/files/common/files'; import { IModelService } from 'vs/editor/common/services/modelService'; -import { isLinux } from 'vs/base/common/platform'; export class TestTextFileEditorModelManager extends TextFileEditorModelManager { @@ -65,11 +64,7 @@ suite('Files - TextFileEditorModelManager', () => { assert(!manager.get(URI.file('foo'))); assert.strictEqual(manager.get(URI.file('/test.html')), model1); - if (isLinux) { - assert.ok(!manager.get(fileUpper)); - } else { - assert.strictEqual(manager.get(fileUpper), model1); - } + assert.ok(!manager.get(fileUpper)); let result = manager.getAll(); assert.strictEqual(3, result.length); @@ -84,11 +79,7 @@ suite('Files - TextFileEditorModelManager', () => { assert.strictEqual(1, result.length); result = manager.getAll(fileUpper); - if (isLinux) { - assert.strictEqual(0, result.length); - } else { - assert.strictEqual(1, result.length); - } + assert.strictEqual(0, result.length); manager.remove(URI.file('')); @@ -101,11 +92,7 @@ suite('Files - TextFileEditorModelManager', () => { manager.remove(fileUpper); result = manager.getAll(); - if (isLinux) { - assert.strictEqual(2, result.length); - } else { - assert.strictEqual(1, result.length); - } + assert.strictEqual(2, result.length); manager.clear(); result = manager.getAll(); diff --git a/src/vs/workbench/services/themes/electron-browser/themeCompatibility.ts b/src/vs/workbench/services/themes/electron-browser/themeCompatibility.ts index 216b0653547..31c8e62a5ca 100644 --- a/src/vs/workbench/services/themes/electron-browser/themeCompatibility.ts +++ b/src/vs/workbench/services/themes/electron-browser/themeCompatibility.ts @@ -10,9 +10,8 @@ import * as colorRegistry from 'vs/platform/theme/common/colorRegistry'; import * as editorColorRegistry from 'vs/editor/common/view/editorColorRegistry'; import * as wordHighlighter from 'vs/editor/contrib/wordHighlighter/common/wordHighlighter'; import { ansiColorIdentifiers } from 'vs/workbench/parts/terminal/electron-browser/terminalColorRegistry'; -import { editorHoverHighlight } from "vs/editor/contrib/hover/browser/hover"; -import { referencesReferenceHighlight, referencesFindMatchHighlight } from "vs/editor/contrib/referenceSearch/browser/referencesWidget"; - +import { editorHoverHighlight } from 'vs/editor/contrib/hover/browser/hover'; +import { referencesReferenceHighlight, referencesFindMatchHighlight } from 'vs/editor/contrib/referenceSearch/browser/referencesWidget'; const settingToColorIdMapping: { [settingId: string]: string[] } = {}; function addSettingMapping(settingId: string, colorId: string) { diff --git a/src/vs/workbench/test/browser/editorStacksModel.test.ts b/src/vs/workbench/test/browser/editorStacksModel.test.ts index 0ae55a05ad5..0fb97b7e694 100644 --- a/src/vs/workbench/test/browser/editorStacksModel.test.ts +++ b/src/vs/workbench/test/browser/editorStacksModel.test.ts @@ -23,7 +23,6 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils'; import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput'; import 'vs/workbench/browser/parts/editor/baseEditor'; -import { isLinux } from 'vs/base/common/platform'; function create(): EditorStacksModel { let inst = new TestInstantiationService(); @@ -1569,17 +1568,10 @@ suite('Editor Stacks Model', () => { assert.equal(model.count(input1Resource), 1); assert.equal(group1.getEditor(input1Resource), input1); - if (isLinux) { - assert.ok(!group1.getEditor(input1ResourceUpper)); - assert.equal(model.count(input1ResourceUpper), 0); - assert.ok(!model.isOpen(input1ResourceUpper)); - assert.ok(!group1.contains(input1ResourceUpper)); - } else { - assert.equal(group1.getEditor(input1ResourceUpper), input1); - assert.equal(model.count(input1ResourceUpper), 1); - assert.ok(model.isOpen(input1ResourceUpper)); - assert.ok(group1.contains(input1ResourceUpper)); - } + assert.ok(!group1.getEditor(input1ResourceUpper)); + assert.equal(model.count(input1ResourceUpper), 0); + assert.ok(!model.isOpen(input1ResourceUpper)); + assert.ok(!group1.contains(input1ResourceUpper)); group2.openEditor(input1); group1.closeEditor(input1); diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index e83df03ddb5..586b7623068 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -53,6 +53,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment' import { IThemeService, ITheme, IThemingParticipant } from 'vs/platform/theme/common/themeService'; import { IDisposable } from 'vs/base/common/lifecycle'; import { Color } from 'vs/base/common/color'; +import { isLinux } from 'vs/base/common/platform'; export function createFileInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput { return instantiationService.createInstance(FileEditorInput, resource, void 0); @@ -93,7 +94,7 @@ export class TestContextService implements IWorkspaceContextService { public isInsideWorkspace(resource: URI): boolean { if (resource && this.workspace) { - return isEqualOrParent(resource.fsPath, this.workspace.resource.fsPath); + return isEqualOrParent(resource.fsPath, this.workspace.resource.fsPath, !isLinux /* ignorecase */); } return false;