diff --git a/src/vs/platform/files/common/files.ts b/src/vs/platform/files/common/files.ts index 731fe0ab7fd04b7e398536226058b7fca288d124..e6f5209589193f65ef4e5125295e2f6822d1bad0 100644 --- a/src/vs/platform/files/common/files.ts +++ b/src/vs/platform/files/common/files.ts @@ -362,7 +362,7 @@ export function isEqualOrParent(path: string, candidate: string, ignoreCase?: bo return path.indexOf(candidate) === 0; } -export function indexOf(path: string, candidate: string): number { +export function indexOf(path: string, candidate: string, ignoreCase?: boolean): number { if (candidate.length > path.length) { return -1; } @@ -371,7 +371,7 @@ export function indexOf(path: string, candidate: string): number { return 0; } - if (!isLinux) { + if (ignoreCase) { path = path.toLowerCase(); candidate = candidate.toLowerCase(); } diff --git a/src/vs/platform/files/test/files.test.ts b/src/vs/platform/files/test/files.test.ts index 6169607ad44976efafc4b83640371640c16dc289..14f4643f7499160b68f0eb52b45626aaacd3878f 100644 --- a/src/vs/platform/files/test/files.test.ts +++ b/src/vs/platform/files/test/files.test.ts @@ -188,19 +188,15 @@ suite('Files', () => { } }); - test('indexOf', function () { - assert.equal(indexOf('/some/path', '/some/path'), 0); - assert.equal(indexOf('/some/path/more', '/some/path'), 0); + test('indexOf (ignorecase)', function () { + assert.equal(indexOf('/some/path', '/some/path', true), 0); + assert.equal(indexOf('/some/path/more', '/some/path', true), 0); - assert.equal(indexOf('c:\\some\\path', 'c:\\some\\path'), 0); - assert.equal(indexOf('c:\\some\\path\\more', 'c:\\some\\path'), 0); + assert.equal(indexOf('c:\\some\\path', 'c:\\some\\path', true), 0); + assert.equal(indexOf('c:\\some\\path\\more', 'c:\\some\\path', true), 0); - assert.equal(indexOf('/some/path', '/some/other/path'), -1); + assert.equal(indexOf('/some/path', '/some/other/path', true), -1); - if (isLinux) { - assert.equal(indexOf('/some/path', '/some/PATH'), -1); - } else { - assert.equal(indexOf('/some/path', '/some/PATH'), 0); - } + assert.equal(indexOf('/some/path', '/some/PATH', true), 0); }); }); \ No newline at end of file diff --git a/src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts b/src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts index b8d8a123b0fd83e8551eef69a56b81824a2b9456..1ea7c0e74529877bf527ace132b66401d0ae98f7 100644 --- a/src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts +++ b/src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts @@ -200,7 +200,7 @@ export class FileEditorTracker implements IWorkbenchContribution { if (oldResource.toString() === resource.toString()) { reopenFileResource = newResource; // file got moved } else { - const index = indexOf(resource.fsPath, oldResource.fsPath); + const index = indexOf(resource.fsPath, oldResource.fsPath, !isLinux /* ignorecase */); reopenFileResource = URI.file(paths.join(newResource.fsPath, resource.fsPath.substr(index + oldResource.fsPath.length + 1))); // parent folder got moved }