From 140b1f6e937b0974c7525aa2d0941a8712608af1 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 2 Aug 2022 00:24:33 +0800 Subject: [PATCH] Normallize drive letter to upper case when convert uri to FsPath, fix #155883 --- src/vs/base/common/uri.ts | 16 +-- .../test/browser/markdownRenderer.test.ts | 4 +- src/vs/base/test/common/console.test.ts | 8 +- src/vs/base/test/common/labels.test.ts | 26 +++-- src/vs/base/test/common/resources.test.ts | 48 ++++----- src/vs/base/test/common/uri.test.ts | 102 +++++++++--------- .../services/decorationRenderOptions.test.ts | 8 +- .../test/node/terminalEnvironment.test.ts | 2 +- .../api/test/browser/extHostWebview.test.ts | 2 +- .../search/test/browser/searchViewlet.test.ts | 8 +- .../browser/links/terminalLinkOpeners.test.ts | 2 +- 11 files changed, 118 insertions(+), 108 deletions(-) diff --git a/src/vs/base/common/uri.ts b/src/vs/base/common/uri.ts index 4aa3825cb4e3e..33390d56667c6 100644 --- a/src/vs/base/common/uri.ts +++ b/src/vs/base/common/uri.ts @@ -591,10 +591,10 @@ export function uriToFsPath(uri: URI, keepDriveLetterCasing: boolean): string { && uri.path.charCodeAt(2) === CharCode.Colon ) { if (!keepDriveLetterCasing) { - // windows drive letter: file:///c:/far/boo - value = uri.path[1].toLowerCase() + uri.path.substr(2); + // windows drive letter: file:///C:/far/boo + value = uri.path[1].toUpperCase() + uri.path.slice(2); } else { - value = uri.path.substr(1); + value = uri.path.slice(1); } } else { // other path @@ -653,16 +653,16 @@ function _asFormatted(uri: URI, skipEncoding: boolean): string { } } if (path) { - // lower-case windows drive letters in /C:/fff or C:/fff + // upper-case windows drive letters in /C:/fff or C:/fff if (path.length >= 3 && path.charCodeAt(0) === CharCode.Slash && path.charCodeAt(2) === CharCode.Colon) { const code = path.charCodeAt(1); - if (code >= CharCode.A && code <= CharCode.Z) { - path = `/${String.fromCharCode(code + 32)}:${path.substr(3)}`; // "/c:".length === 3 + if (code >= CharCode.a && code <= CharCode.z) { + path = `/${String.fromCharCode(code - 32)}:${path.substr(3)}`; // "/C:".length === 3 } } else if (path.length >= 2 && path.charCodeAt(1) === CharCode.Colon) { const code = path.charCodeAt(0); - if (code >= CharCode.A && code <= CharCode.Z) { - path = `${String.fromCharCode(code + 32)}:${path.substr(2)}`; // "/c:".length === 3 + if (code >= CharCode.a && code <= CharCode.z) { + path = `${String.fromCharCode(code - 32)}:${path.substr(2)}`; // "/C:".length === 3 } } // encode the rest of the path diff --git a/src/vs/base/test/browser/markdownRenderer.test.ts b/src/vs/base/test/browser/markdownRenderer.test.ts index 3852b15797e05..c9ac43c3581ab 100644 --- a/src/vs/base/test/browser/markdownRenderer.test.ts +++ b/src/vs/base/test/browser/markdownRenderer.test.ts @@ -204,7 +204,7 @@ suite('MarkdownRenderer', () => { test('npm Hover Run Script not working #90855', function () { - const md: IMarkdownString = JSON.parse('{"value":"[Run Script](command:npm.runScriptFromHover?%7B%22documentUri%22%3A%7B%22%24mid%22%3A1%2C%22fsPath%22%3A%22c%3A%5C%5CUsers%5C%5Cjrieken%5C%5CCode%5C%5C_sample%5C%5Cfoo%5C%5Cpackage.json%22%2C%22_sep%22%3A1%2C%22external%22%3A%22file%3A%2F%2F%2Fc%253A%2FUsers%2Fjrieken%2FCode%2F_sample%2Ffoo%2Fpackage.json%22%2C%22path%22%3A%22%2Fc%3A%2FUsers%2Fjrieken%2FCode%2F_sample%2Ffoo%2Fpackage.json%22%2C%22scheme%22%3A%22file%22%7D%2C%22script%22%3A%22echo%22%7D \\"Run the script as a task\\")","supportThemeIcons":false,"isTrusted":true,"uris":{"__uri_e49443":{"$mid":1,"fsPath":"c:\\\\Users\\\\jrieken\\\\Code\\\\_sample\\\\foo\\\\package.json","_sep":1,"external":"file:///c%3A/Users/jrieken/Code/_sample/foo/package.json","path":"/c:/Users/jrieken/Code/_sample/foo/package.json","scheme":"file"},"command:npm.runScriptFromHover?%7B%22documentUri%22%3A%7B%22%24mid%22%3A1%2C%22fsPath%22%3A%22c%3A%5C%5CUsers%5C%5Cjrieken%5C%5CCode%5C%5C_sample%5C%5Cfoo%5C%5Cpackage.json%22%2C%22_sep%22%3A1%2C%22external%22%3A%22file%3A%2F%2F%2Fc%253A%2FUsers%2Fjrieken%2FCode%2F_sample%2Ffoo%2Fpackage.json%22%2C%22path%22%3A%22%2Fc%3A%2FUsers%2Fjrieken%2FCode%2F_sample%2Ffoo%2Fpackage.json%22%2C%22scheme%22%3A%22file%22%7D%2C%22script%22%3A%22echo%22%7D":{"$mid":1,"path":"npm.runScriptFromHover","scheme":"command","query":"{\\"documentUri\\":\\"__uri_e49443\\",\\"script\\":\\"echo\\"}"}}}'); + const md: IMarkdownString = JSON.parse('{"value":"[Run Script](command:npm.runScriptFromHover?%7B%22documentUri%22%3A%7B%22%24mid%22%3A1%2C%22fsPath%22%3A%22c%3A%5C%5CUsers%5C%5Cjrieken%5C%5CCode%5C%5C_sample%5C%5Cfoo%5C%5Cpackage.json%22%2C%22_sep%22%3A1%2C%22external%22%3A%22file%3A%2F%2F%2Fc%253A%2FUsers%2Fjrieken%2FCode%2F_sample%2Ffoo%2Fpackage.json%22%2C%22path%22%3A%22%2Fc%3A%2FUsers%2Fjrieken%2FCode%2F_sample%2Ffoo%2Fpackage.json%22%2C%22scheme%22%3A%22file%22%7D%2C%22script%22%3A%22echo%22%7D \\"Run the script as a task\\")","supportThemeIcons":false,"isTrusted":true,"uris":{"__uri_e49443":{"$mid":1,"fsPath":"c:\\\\Users\\\\jrieken\\\\Code\\\\_sample\\\\foo\\\\package.json","_sep":1,"external":"file:///C%3A/Users/jrieken/Code/_sample/foo/package.json","path":"/c:/Users/jrieken/Code/_sample/foo/package.json","scheme":"file"},"command:npm.runScriptFromHover?%7B%22documentUri%22%3A%7B%22%24mid%22%3A1%2C%22fsPath%22%3A%22c%3A%5C%5CUsers%5C%5Cjrieken%5C%5CCode%5C%5C_sample%5C%5Cfoo%5C%5Cpackage.json%22%2C%22_sep%22%3A1%2C%22external%22%3A%22file%3A%2F%2F%2Fc%253A%2FUsers%2Fjrieken%2FCode%2F_sample%2Ffoo%2Fpackage.json%22%2C%22path%22%3A%22%2Fc%3A%2FUsers%2Fjrieken%2FCode%2F_sample%2Ffoo%2Fpackage.json%22%2C%22scheme%22%3A%22file%22%7D%2C%22script%22%3A%22echo%22%7D":{"$mid":1,"path":"npm.runScriptFromHover","scheme":"command","query":"{\\"documentUri\\":\\"__uri_e49443\\",\\"script\\":\\"echo\\"}"}}}'); const element = renderMarkdown(md).element; const anchor = element.querySelector('a')!; @@ -216,7 +216,7 @@ suite('MarkdownRenderer', () => { const data = <{ script: string; documentUri: URI }>parse(decodeURIComponent(uri.query)); assert.ok(data); assert.strictEqual(data.script, 'echo'); - assert.ok(data.documentUri.toString().startsWith('file:///c%3A/')); + assert.ok(data.documentUri.toString().startsWith('file:///C%3A/')); }); test('Should not render command links by default', () => { diff --git a/src/vs/base/test/common/console.test.ts b/src/vs/base/test/common/console.test.ts index 36439bc820df6..703052452bcd1 100644 --- a/src/vs/base/test/common/console.test.ts +++ b/src/vs/base/test/common/console.test.ts @@ -24,17 +24,17 @@ suite('Console', () => { assert.strictEqual(frame.line, 18); assert.strictEqual(frame.column, 17); - stack = 'at c:\\Users\\someone\\Desktop\\end-js\\extension.js:18:17'; + stack = 'at C:\\Users\\someone\\Desktop\\end-js\\extension.js:18:17'; frame = getFirstFrame(stack)!; - assert.strictEqual(frame.uri.fsPath, 'c:\\Users\\someone\\Desktop\\end-js\\extension.js'); + assert.strictEqual(frame.uri.fsPath, 'C:\\Users\\someone\\Desktop\\end-js\\extension.js'); assert.strictEqual(frame.line, 18); assert.strictEqual(frame.column, 17); - stack = 'at e.$executeContributedCommand(c:\\Users\\someone\\Desktop\\end-js\\extension.js:18:17)'; + stack = 'at e.$executeContributedCommand(C:\\Users\\someone\\Desktop\\end-js\\extension.js:18:17)'; frame = getFirstFrame(stack)!; - assert.strictEqual(frame.uri.fsPath, 'c:\\Users\\someone\\Desktop\\end-js\\extension.js'); + assert.strictEqual(frame.uri.fsPath, 'C:\\Users\\someone\\Desktop\\end-js\\extension.js'); assert.strictEqual(frame.line, 18); assert.strictEqual(frame.column, 17); diff --git a/src/vs/base/test/common/labels.test.ts b/src/vs/base/test/common/labels.test.ts index 82bb2d98a75ba..3f5e69f7b287a 100644 --- a/src/vs/base/test/common/labels.test.ts +++ b/src/vs/base/test/common/labels.test.ts @@ -155,24 +155,24 @@ suite('Labels', () => { }); test('getPathLabel', () => { - const winFileUri = URI.file('c:/some/folder/file.txt'); + const winFileUri = URI.file('C:/some/folder/file.txt'); const nixFileUri = URI.file('/some/folder/file.txt'); - const uncFileUri = URI.file('c:/some/folder/file.txt').with({ authority: 'auth' }); + const uncFileUri = URI.file('C:/some/folder/file.txt').with({ authority: 'auth' }); const remoteFileUri = URI.file('/some/folder/file.txt').with({ scheme: 'vscode-test', authority: 'auth' }); // Basics assert.strictEqual(labels.getPathLabel(winFileUri, { os: OperatingSystem.Windows }), 'C:\\some\\folder\\file.txt'); - assert.strictEqual(labels.getPathLabel(winFileUri, { os: OperatingSystem.Macintosh }), 'c:/some/folder/file.txt'); - assert.strictEqual(labels.getPathLabel(winFileUri, { os: OperatingSystem.Linux }), 'c:/some/folder/file.txt'); + assert.strictEqual(labels.getPathLabel(winFileUri, { os: OperatingSystem.Macintosh }), 'C:/some/folder/file.txt'); + assert.strictEqual(labels.getPathLabel(winFileUri, { os: OperatingSystem.Linux }), 'C:/some/folder/file.txt'); assert.strictEqual(labels.getPathLabel(nixFileUri, { os: OperatingSystem.Windows }), '\\some\\folder\\file.txt'); assert.strictEqual(labels.getPathLabel(nixFileUri, { os: OperatingSystem.Macintosh }), '/some/folder/file.txt'); assert.strictEqual(labels.getPathLabel(nixFileUri, { os: OperatingSystem.Linux }), '/some/folder/file.txt'); - assert.strictEqual(labels.getPathLabel(uncFileUri, { os: OperatingSystem.Windows }), '\\\\auth\\c:\\some\\folder\\file.txt'); - assert.strictEqual(labels.getPathLabel(uncFileUri, { os: OperatingSystem.Macintosh }), '/auth/c:/some/folder/file.txt'); - assert.strictEqual(labels.getPathLabel(uncFileUri, { os: OperatingSystem.Linux }), '/auth/c:/some/folder/file.txt'); + assert.strictEqual(labels.getPathLabel(uncFileUri, { os: OperatingSystem.Windows }), '\\\\auth\\C:\\some\\folder\\file.txt'); + assert.strictEqual(labels.getPathLabel(uncFileUri, { os: OperatingSystem.Macintosh }), '/auth/C:/some/folder/file.txt'); + assert.strictEqual(labels.getPathLabel(uncFileUri, { os: OperatingSystem.Linux }), '/auth/C:/some/folder/file.txt'); assert.strictEqual(labels.getPathLabel(remoteFileUri, { os: OperatingSystem.Windows }), '\\some\\folder\\file.txt'); assert.strictEqual(labels.getPathLabel(remoteFileUri, { os: OperatingSystem.Macintosh }), '/some/folder/file.txt'); @@ -203,7 +203,7 @@ suite('Labels', () => { // Relative - const winFolder = URI.file('c:/some'); + const winFolder = URI.file('C:/some'); const winRelativePathProvider: labels.IRelativePathProvider = { getWorkspace() { return { folders: [{ uri: winFolder }] }; }, getWorkspaceFolder(resource) { return { uri: winFolder }; } @@ -227,4 +227,14 @@ suite('Labels', () => { assert.strictEqual(labels.getPathLabel(nixUntitledUri, { os: OperatingSystem.Macintosh, relative: nixRelativePathProvider }), 'folder/file.txt'); assert.strictEqual(labels.getPathLabel(nixUntitledUri, { os: OperatingSystem.Linux, relative: nixRelativePathProvider }), 'folder/file.txt'); }); + + test('winDiskLetter', () => { + const winFileUri = URI.file('c:/some/folder/file.txt'); + + + assert.strictEqual(labels.getPathLabel(winFileUri, { os: OperatingSystem.Windows }), 'C:\\some\\folder\\file.txt'); + assert.strictEqual(labels.getPathLabel(winFileUri, { os: OperatingSystem.Macintosh }), 'C:/some/folder/file.txt'); + assert.strictEqual(labels.getPathLabel(winFileUri, { os: OperatingSystem.Linux }), 'C:/some/folder/file.txt'); + }); + }); diff --git a/src/vs/base/test/common/resources.test.ts b/src/vs/base/test/common/resources.test.ts index a7b13f1251690..894905f78b9de 100644 --- a/src/vs/base/test/common/resources.test.ts +++ b/src/vs/base/test/common/resources.test.ts @@ -45,12 +45,12 @@ suite('Resources', () => { test('dirname', () => { if (isWindows) { - assert.strictEqual(dirname(URI.file('c:\\some\\file\\test.txt')).toString(), 'file:///c%3A/some/file'); - assert.strictEqual(dirname(URI.file('c:\\some\\file')).toString(), 'file:///c%3A/some'); - assert.strictEqual(dirname(URI.file('c:\\some\\file\\')).toString(), 'file:///c%3A/some'); - assert.strictEqual(dirname(URI.file('c:\\some')).toString(), 'file:///c%3A/'); - assert.strictEqual(dirname(URI.file('C:\\some')).toString(), 'file:///c%3A/'); - assert.strictEqual(dirname(URI.file('c:\\')).toString(), 'file:///c%3A/'); + assert.strictEqual(dirname(URI.file('c:\\some\\file\\test.txt')).toString(), 'file:///C%3A/some/file'); + assert.strictEqual(dirname(URI.file('c:\\some\\file')).toString(), 'file:///C%3A/some'); + assert.strictEqual(dirname(URI.file('c:\\some\\file\\')).toString(), 'file:///C%3A/some'); + assert.strictEqual(dirname(URI.file('c:\\some')).toString(), 'file:///C%3A/'); + assert.strictEqual(dirname(URI.file('C:\\some')).toString(), 'file:///C%3A/'); + assert.strictEqual(dirname(URI.file('c:\\')).toString(), 'file:///C%3A/'); } else { assert.strictEqual(dirname(URI.file('/some/file/test.txt')).toString(), 'file:///some/file'); assert.strictEqual(dirname(URI.file('/some/file/')).toString(), 'file:///some'); @@ -91,15 +91,15 @@ suite('Resources', () => { test('joinPath', () => { if (isWindows) { - assert.strictEqual(joinPath(URI.file('c:\\foo\\bar'), '/file.js').toString(), 'file:///c%3A/foo/bar/file.js'); - assert.strictEqual(joinPath(URI.file('c:\\foo\\bar\\'), 'file.js').toString(), 'file:///c%3A/foo/bar/file.js'); - assert.strictEqual(joinPath(URI.file('c:\\foo\\bar\\'), '/file.js').toString(), 'file:///c%3A/foo/bar/file.js'); - assert.strictEqual(joinPath(URI.file('c:\\'), '/file.js').toString(), 'file:///c%3A/file.js'); - assert.strictEqual(joinPath(URI.file('c:\\'), 'bar/file.js').toString(), 'file:///c%3A/bar/file.js'); - assert.strictEqual(joinPath(URI.file('c:\\foo'), './file.js').toString(), 'file:///c%3A/foo/file.js'); - assert.strictEqual(joinPath(URI.file('c:\\foo'), '/./file.js').toString(), 'file:///c%3A/foo/file.js'); - assert.strictEqual(joinPath(URI.file('C:\\foo'), '../file.js').toString(), 'file:///c%3A/file.js'); - assert.strictEqual(joinPath(URI.file('C:\\foo\\.'), '../file.js').toString(), 'file:///c%3A/file.js'); + assert.strictEqual(joinPath(URI.file('c:\\foo\\bar'), '/file.js').toString(), 'file:///C%3A/foo/bar/file.js'); + assert.strictEqual(joinPath(URI.file('c:\\foo\\bar\\'), 'file.js').toString(), 'file:///C%3A/foo/bar/file.js'); + assert.strictEqual(joinPath(URI.file('c:\\foo\\bar\\'), '/file.js').toString(), 'file:///C%3A/foo/bar/file.js'); + assert.strictEqual(joinPath(URI.file('c:\\'), '/file.js').toString(), 'file:///C%3A/file.js'); + assert.strictEqual(joinPath(URI.file('c:\\'), 'bar/file.js').toString(), 'file:///C%3A/bar/file.js'); + assert.strictEqual(joinPath(URI.file('c:\\foo'), './file.js').toString(), 'file:///C%3A/foo/file.js'); + assert.strictEqual(joinPath(URI.file('c:\\foo'), '/./file.js').toString(), 'file:///C%3A/foo/file.js'); + assert.strictEqual(joinPath(URI.file('C:\\foo'), '../file.js').toString(), 'file:///C%3A/file.js'); + assert.strictEqual(joinPath(URI.file('C:\\foo\\.'), '../file.js').toString(), 'file:///C%3A/file.js'); } else { assert.strictEqual(joinPath(URI.file('/foo/bar'), '/file.js').toString(), 'file:///foo/bar/file.js'); assert.strictEqual(joinPath(URI.file('/foo/bar'), 'file.js').toString(), 'file:///foo/bar/file.js'); @@ -125,15 +125,15 @@ suite('Resources', () => { test('normalizePath', () => { if (isWindows) { - assert.strictEqual(normalizePath(URI.file('c:\\foo\\.\\bar')).toString(), 'file:///c%3A/foo/bar'); - assert.strictEqual(normalizePath(URI.file('c:\\foo\\.')).toString(), 'file:///c%3A/foo'); - assert.strictEqual(normalizePath(URI.file('c:\\foo\\.\\')).toString(), 'file:///c%3A/foo/'); - assert.strictEqual(normalizePath(URI.file('c:\\foo\\..')).toString(), 'file:///c%3A/'); - assert.strictEqual(normalizePath(URI.file('c:\\foo\\..\\bar')).toString(), 'file:///c%3A/bar'); - assert.strictEqual(normalizePath(URI.file('c:\\foo\\..\\..\\bar')).toString(), 'file:///c%3A/bar'); - assert.strictEqual(normalizePath(URI.file('c:\\foo\\foo\\..\\..\\bar')).toString(), 'file:///c%3A/bar'); - assert.strictEqual(normalizePath(URI.file('C:\\foo\\foo\\.\\..\\..\\bar')).toString(), 'file:///c%3A/bar'); - assert.strictEqual(normalizePath(URI.file('C:\\foo\\foo\\.\\..\\some\\..\\bar')).toString(), 'file:///c%3A/foo/bar'); + assert.strictEqual(normalizePath(URI.file('c:\\foo\\.\\bar')).toString(), 'file:///C%3A/foo/bar'); + assert.strictEqual(normalizePath(URI.file('c:\\foo\\.')).toString(), 'file:///C%3A/foo'); + assert.strictEqual(normalizePath(URI.file('c:\\foo\\.\\')).toString(), 'file:///C%3A/foo/'); + assert.strictEqual(normalizePath(URI.file('c:\\foo\\..')).toString(), 'file:///C%3A/'); + assert.strictEqual(normalizePath(URI.file('c:\\foo\\..\\bar')).toString(), 'file:///C%3A/bar'); + assert.strictEqual(normalizePath(URI.file('c:\\foo\\..\\..\\bar')).toString(), 'file:///C%3A/bar'); + assert.strictEqual(normalizePath(URI.file('c:\\foo\\foo\\..\\..\\bar')).toString(), 'file:///C%3A/bar'); + assert.strictEqual(normalizePath(URI.file('C:\\foo\\foo\\.\\..\\..\\bar')).toString(), 'file:///C%3A/bar'); + assert.strictEqual(normalizePath(URI.file('C:\\foo\\foo\\.\\..\\some\\..\\bar')).toString(), 'file:///C%3A/foo/bar'); } else { assert.strictEqual(normalizePath(URI.file('/foo/./bar')).toString(), 'file:///foo/bar'); assert.strictEqual(normalizePath(URI.file('/foo/.')).toString(), 'file:///foo'); diff --git a/src/vs/base/test/common/uri.test.ts b/src/vs/base/test/common/uri.test.ts index 3aedee9c4f185..d77638d8e4e54 100644 --- a/src/vs/base/test/common/uri.test.ts +++ b/src/vs/base/test/common/uri.test.ts @@ -9,38 +9,38 @@ import { URI, UriComponents } from 'vs/base/common/uri'; suite('URI', () => { test('file#toString', () => { - assert.strictEqual(URI.file('c:/win/path').toString(), 'file:///c%3A/win/path'); - assert.strictEqual(URI.file('C:/win/path').toString(), 'file:///c%3A/win/path'); - assert.strictEqual(URI.file('c:/win/path/').toString(), 'file:///c%3A/win/path/'); - assert.strictEqual(URI.file('/c:/win/path').toString(), 'file:///c%3A/win/path'); + assert.strictEqual(URI.file('c:/win/path').toString(), 'file:///C%3A/win/path'); + assert.strictEqual(URI.file('C:/win/path').toString(), 'file:///C%3A/win/path'); + assert.strictEqual(URI.file('C:/win/path/').toString(), 'file:///C%3A/win/path/'); + assert.strictEqual(URI.file('/C:/win/path').toString(), 'file:///C%3A/win/path'); }); test('URI.file (win-special)', () => { if (isWindows) { - assert.strictEqual(URI.file('c:\\win\\path').toString(), 'file:///c%3A/win/path'); - assert.strictEqual(URI.file('c:\\win/path').toString(), 'file:///c%3A/win/path'); + assert.strictEqual(URI.file('C:\\win\\path').toString(), 'file:///C%3A/win/path'); + assert.strictEqual(URI.file('C:\\win/path').toString(), 'file:///C%3A/win/path'); } else { - assert.strictEqual(URI.file('c:\\win\\path').toString(), 'file:///c%3A%5Cwin%5Cpath'); - assert.strictEqual(URI.file('c:\\win/path').toString(), 'file:///c%3A%5Cwin/path'); + assert.strictEqual(URI.file('C:\\win\\path').toString(), 'file:///C%3A%5Cwin%5Cpath'); + assert.strictEqual(URI.file('C:\\win/path').toString(), 'file:///C%3A%5Cwin/path'); } }); test('file#fsPath (win-special)', () => { if (isWindows) { - assert.strictEqual(URI.file('c:\\win\\path').fsPath, 'c:\\win\\path'); - assert.strictEqual(URI.file('c:\\win/path').fsPath, 'c:\\win\\path'); - - assert.strictEqual(URI.file('c:/win/path').fsPath, 'c:\\win\\path'); - assert.strictEqual(URI.file('c:/win/path/').fsPath, 'c:\\win\\path\\'); - assert.strictEqual(URI.file('C:/win/path').fsPath, 'c:\\win\\path'); - assert.strictEqual(URI.file('/c:/win/path').fsPath, 'c:\\win\\path'); - assert.strictEqual(URI.file('./c/win/path').fsPath, '\\.\\c\\win\\path'); + assert.strictEqual(URI.file('C:\\win\\path').fsPath, 'C:\\win\\path'); + assert.strictEqual(URI.file('C:\\win/path').fsPath, 'C:\\win\\path'); + + assert.strictEqual(URI.file('C:/win/path').fsPath, 'C:\\win\\path'); + assert.strictEqual(URI.file('C:/win/path/').fsPath, 'C:\\win\\path\\'); + assert.strictEqual(URI.file('c:/win/path').fsPath, 'C:\\win\\path'); + assert.strictEqual(URI.file('/C:/win/path').fsPath, 'C:\\win\\path'); + assert.strictEqual(URI.file('./C/win/path').fsPath, '\\.\\C\\win\\path'); } else { - assert.strictEqual(URI.file('c:/win/path').fsPath, 'c:/win/path'); - assert.strictEqual(URI.file('c:/win/path/').fsPath, 'c:/win/path/'); - assert.strictEqual(URI.file('C:/win/path').fsPath, 'c:/win/path'); - assert.strictEqual(URI.file('/c:/win/path').fsPath, 'c:/win/path'); + assert.strictEqual(URI.file('C:/win/path').fsPath, 'C:/win/path'); + assert.strictEqual(URI.file('C:/win/path/').fsPath, 'C:/win/path/'); + assert.strictEqual(URI.file('c:/win/path').fsPath, 'C:/win/path'); + assert.strictEqual(URI.file('/C:/win/path').fsPath, 'C:/win/path'); assert.strictEqual(URI.file('./c/win/path').fsPath, '/./c/win/path'); } }); @@ -143,13 +143,13 @@ suite('URI', () => { assert.strictEqual(value.query, 't=1234'); assert.strictEqual(value.fragment, ''); - value = URI.parse('file:///c:/test/me'); + value = URI.parse('file:///C:/test/me'); assert.strictEqual(value.scheme, 'file'); assert.strictEqual(value.authority, ''); - assert.strictEqual(value.path, '/c:/test/me'); + assert.strictEqual(value.path, '/C:/test/me'); assert.strictEqual(value.fragment, ''); assert.strictEqual(value.query, ''); - assert.strictEqual(value.fsPath, isWindows ? 'c:\\test\\me' : 'c:/test/me'); + assert.strictEqual(value.fsPath, isWindows ? 'C:\\test\\me' : 'C:/test/me'); value = URI.parse('file://shares/files/c%23/p.cs'); assert.strictEqual(value.scheme, 'file'); @@ -159,17 +159,17 @@ suite('URI', () => { assert.strictEqual(value.query, ''); assert.strictEqual(value.fsPath, isWindows ? '\\\\shares\\files\\c#\\p.cs' : '//shares/files/c#/p.cs'); - value = URI.parse('file:///c:/Source/Z%C3%BCrich%20or%20Zurich%20(%CB%88zj%CA%8A%C9%99r%C9%AAk,/Code/resources/app/plugins/c%23/plugin.json'); + value = URI.parse('file:///C:/Source/Z%C3%BCrich%20or%20Zurich%20(%CB%88zj%CA%8A%C9%99r%C9%AAk,/Code/resources/app/plugins/c%23/plugin.json'); assert.strictEqual(value.scheme, 'file'); assert.strictEqual(value.authority, ''); - assert.strictEqual(value.path, '/c:/Source/Zürich or Zurich (ˈzjʊərɪk,/Code/resources/app/plugins/c#/plugin.json'); + assert.strictEqual(value.path, '/C:/Source/Zürich or Zurich (ˈzjʊərɪk,/Code/resources/app/plugins/c#/plugin.json'); assert.strictEqual(value.fragment, ''); assert.strictEqual(value.query, ''); - value = URI.parse('file:///c:/test %25/path'); + value = URI.parse('file:///C:/test %25/path'); assert.strictEqual(value.scheme, 'file'); assert.strictEqual(value.authority, ''); - assert.strictEqual(value.path, '/c:/test %/path'); + assert.strictEqual(value.path, '/C:/test %/path'); assert.strictEqual(value.fragment, ''); assert.strictEqual(value.query, ''); @@ -236,9 +236,9 @@ suite('URI', () => { test('URI#file, win-speciale', () => { if (isWindows) { - let value = URI.file('c:\\test\\drive'); - assert.strictEqual(value.path, '/c:/test/drive'); - assert.strictEqual(value.toString(), 'file:///c%3A/test/drive'); + let value = URI.file('C:\\test\\drive'); + assert.strictEqual(value.path, '/C:/test/drive'); + assert.strictEqual(value.toString(), 'file:///C%3A/test/drive'); value = URI.file('\\\\shäres\\path\\c#\\plugin.json'); assert.strictEqual(value.scheme, 'file'); @@ -256,17 +256,17 @@ suite('URI', () => { assert.strictEqual(value.fragment, ''); assert.strictEqual(value.toString(), 'file://localhost/c%24/GitDevelopment/express'); - value = URI.file('c:\\test with %\\path'); - assert.strictEqual(value.path, '/c:/test with %/path'); - assert.strictEqual(value.toString(), 'file:///c%3A/test%20with%20%25/path'); + value = URI.file('C:\\test with %\\path'); + assert.strictEqual(value.path, '/C:/test with %/path'); + assert.strictEqual(value.toString(), 'file:///C%3A/test%20with%20%25/path'); - value = URI.file('c:\\test with %25\\path'); - assert.strictEqual(value.path, '/c:/test with %25/path'); - assert.strictEqual(value.toString(), 'file:///c%3A/test%20with%20%2525/path'); + value = URI.file('C:\\test with %25\\path'); + assert.strictEqual(value.path, '/C:/test with %25/path'); + assert.strictEqual(value.toString(), 'file:///C%3A/test%20with%20%2525/path'); - value = URI.file('c:\\test with %25\\c#code'); - assert.strictEqual(value.path, '/c:/test with %25/c#code'); - assert.strictEqual(value.toString(), 'file:///c%3A/test%20with%20%2525/c%23code'); + value = URI.file('C:\\test with %25\\c#code'); + assert.strictEqual(value.path, '/C:/test with %25/c#code'); + assert.strictEqual(value.toString(), 'file:///C%3A/test%20with%20%2525/c%23code'); value = URI.file('\\\\shares'); assert.strictEqual(value.scheme, 'file'); @@ -320,8 +320,8 @@ suite('URI', () => { }); test('URI#toString, lower-case windows drive letter', () => { - assert.strictEqual(URI.parse('untitled:c:/Users/jrieken/Code/abc.txt').toString(), 'untitled:c%3A/Users/jrieken/Code/abc.txt'); - assert.strictEqual(URI.parse('untitled:C:/Users/jrieken/Code/abc.txt').toString(), 'untitled:c%3A/Users/jrieken/Code/abc.txt'); + assert.strictEqual(URI.parse('untitled:C:/Users/jrieken/Code/abc.txt').toString(), 'untitled:C%3A/Users/jrieken/Code/abc.txt'); + assert.strictEqual(URI.parse('untitled:C:/Users/jrieken/Code/abc.txt').toString(), 'untitled:C%3A/Users/jrieken/Code/abc.txt'); }); test('URI#toString, escape all the bits', () => { @@ -365,8 +365,8 @@ suite('URI', () => { assert.strictEqual(value.toString(), value2.toString()); }; - test('file:///c:/alex.txt', isWindows ? 'c:\\alex.txt' : 'c:/alex.txt'); - test('file:///c:/Source/Z%C3%BCrich%20or%20Zurich%20(%CB%88zj%CA%8A%C9%99r%C9%AAk,/Code/resources/app/plugins', isWindows ? 'c:\\Source\\Zürich or Zurich (ˈzjʊərɪk,\\Code\\resources\\app\\plugins' : 'c:/Source/Zürich or Zurich (ˈzjʊərɪk,/Code/resources/app/plugins'); + test('file:///C:/alex.txt', isWindows ? 'C:\\alex.txt' : 'C:/alex.txt'); + test('file:///C:/Source/Z%C3%BCrich%20or%20Zurich%20(%CB%88zj%CA%8A%C9%99r%C9%AAk,/Code/resources/app/plugins', isWindows ? 'C:\\Source\\Zürich or Zurich (ˈzjʊərɪk,\\Code\\resources\\app\\plugins' : 'C:/Source/Zürich or Zurich (ˈzjʊərɪk,/Code/resources/app/plugins'); test('file://monacotools/folder/isi.txt', isWindows ? '\\\\monacotools\\folder\\isi.txt' : '//monacotools/folder/isi.txt'); test('file://monacotools1/certificates/SSL/', isWindows ? '\\\\monacotools1\\certificates\\SSL\\' : '//monacotools1/certificates/SSL/'); }); @@ -506,7 +506,7 @@ suite('URI', () => { const values = [ URI.parse('http://localhost:8080/far'), - URI.file('c:\\test with %25\\c#code'), + URI.file('C:\\test with %25\\c#code'), URI.file('\\\\shäres\\path\\c#\\plugin.json'), URI.parse('http://api/files/test.me?t=1234'), URI.parse('http://api/files/test.me?t=1234#fff'), @@ -573,9 +573,9 @@ suite('URI', () => { if (isWindows) { this.skip(); } - assertJoined(('file:///c:/foo/'), '../../bazz', 'file:///bazz', false); - assertJoined(('file://server/share/c:/'), '../../bazz', 'file://server/bazz', false); - assertJoined(('file://server/share/c:'), '../../bazz', 'file://server/bazz', false); + assertJoined(('file:///C:/foo/'), '../../bazz', 'file:///bazz', false); + assertJoined(('file://server/share/C:/'), '../../bazz', 'file://server/bazz', false); + assertJoined(('file://server/share/C:'), '../../bazz', 'file://server/bazz', false); assertJoined(('file://ser/foo/'), '../../bazz', 'file://ser/bazz', false); // Firefox -> Different, Edge, Chrome, Safar -> OK assertJoined(('file://ser/foo'), '../../bazz', 'file://ser/bazz', false); // Firefox -> Different, Edge, Chrome, Safar -> OK @@ -585,14 +585,14 @@ suite('URI', () => { if (!isWindows) { this.skip(); } - assertJoined(('file:///c:/foo/'), '../../bazz', 'file:///c:/bazz', false); - assertJoined(('file://server/share/c:/'), '../../bazz', 'file://server/share/bazz', false); - assertJoined(('file://server/share/c:'), '../../bazz', 'file://server/share/bazz', false); + assertJoined(('file:///C:/foo/'), '../../bazz', 'file:///C:/bazz', false); + assertJoined(('file://server/share/C:/'), '../../bazz', 'file://server/share/bazz', false); + assertJoined(('file://server/share/C:'), '../../bazz', 'file://server/share/bazz', false); assertJoined(('file://ser/foo/'), '../../bazz', 'file://ser/foo/bazz', false); assertJoined(('file://ser/foo'), '../../bazz', 'file://ser/foo/bazz', false); //https://github.com/microsoft/vscode/issues/93831 - assertJoined('file:///c:/foo/bar', './other/foo.img', 'file:///c:/foo/bar/other/foo.img', false); + assertJoined('file:///C:/foo/bar', './other/foo.img', 'file:///C:/foo/bar/other/foo.img', false); }); }); diff --git a/src/vs/editor/test/browser/services/decorationRenderOptions.test.ts b/src/vs/editor/test/browser/services/decorationRenderOptions.test.ts index 68fa314066d3c..f8c1f68dacd94 100644 --- a/src/vs/editor/test/browser/services/decorationRenderOptions.test.ts +++ b/src/vs/editor/test/browser/services/decorationRenderOptions.test.ts @@ -121,13 +121,13 @@ suite('Decoration Render Options', () => { if (platform.isWindows) { // windows file path (used as string) - s.registerDecorationType('test', 'example', { gutterIconPath: URI.file('c:\\files\\miles\\more.png') }); - assertBackground('file:///c:/files/miles/more.png', 'vscode-file://vscode-app/c:/files/miles/more.png'); + s.registerDecorationType('test', 'example', { gutterIconPath: URI.file('C:\\files\\miles\\more.png') }); + assertBackground('file:///C:/files/miles/more.png', 'vscode-file://vscode-app/C:/files/miles/more.png'); s.removeDecorationType('example'); // single quote must always be escaped/encoded - s.registerDecorationType('test', 'example', { gutterIconPath: URI.file('c:\\files\\foo\\b\'ar.png') }); - assertBackground('file:///c:/files/foo/b%27ar.png', 'vscode-file://vscode-app/c:/files/foo/b%27ar.png'); + s.registerDecorationType('test', 'example', { gutterIconPath: URI.file('C:\\files\\foo\\b\'ar.png') }); + assertBackground('file:///C:/files/foo/b%27ar.png', 'vscode-file://vscode-app/C:/files/foo/b%27ar.png'); s.removeDecorationType('example'); } else { // unix file path (used as string) diff --git a/src/vs/platform/terminal/test/node/terminalEnvironment.test.ts b/src/vs/platform/terminal/test/node/terminalEnvironment.test.ts index b6f76ccafbe5f..04d4300479667 100644 --- a/src/vs/platform/terminal/test/node/terminalEnvironment.test.ts +++ b/src/vs/platform/terminal/test/node/terminalEnvironment.test.ts @@ -11,7 +11,7 @@ import { getShellIntegrationInjection, IShellIntegrationConfigInjection } from ' const enabledProcessOptions: ITerminalProcessOptions['shellIntegration'] = { enabled: true }; const disabledProcessOptions: ITerminalProcessOptions['shellIntegration'] = { enabled: false }; const pwshExe = process.platform === 'win32' ? 'pwsh.exe' : 'pwsh'; -const repoRoot = process.platform === 'win32' ? process.cwd()[0].toLowerCase() + process.cwd().substring(1) : process.cwd(); +const repoRoot = process.platform === 'win32' ? process.cwd()[0].toUpperCase() + process.cwd().substring(1) : process.cwd(); const logService = new NullLogService(); suite('platform - terminalEnvironment', () => { diff --git a/src/vs/workbench/api/test/browser/extHostWebview.test.ts b/src/vs/workbench/api/test/browser/extHostWebview.test.ts index 50327ab707d2b..3ae653365f84b 100644 --- a/src/vs/workbench/api/test/browser/extHostWebview.test.ts +++ b/src/vs/workbench/api/test/browser/extHostWebview.test.ts @@ -107,7 +107,7 @@ suite('ExtHostWebview', () => { assert.strictEqual( (webview.webview.asWebviewUri(URI.parse('file:///c:/codey/file.txt')).toString()), - `https://file%2B.vscode-resource.${webviewResourceBaseHost}/c%3A/codey/file.txt`, + `https://file%2B.vscode-resource.${webviewResourceBaseHost}/C%3A/codey/file.txt`, 'Windows C drive' ); }); diff --git a/src/vs/workbench/contrib/search/test/browser/searchViewlet.test.ts b/src/vs/workbench/contrib/search/test/browser/searchViewlet.test.ts index 28cf97e0b7717..0d1b2000a18a3 100644 --- a/src/vs/workbench/contrib/search/test/browser/searchViewlet.test.ts +++ b/src/vs/workbench/contrib/search/test/browser/searchViewlet.test.ts @@ -44,12 +44,12 @@ suite('Search - Viewlet', () => { type: QueryType.Text, contentPattern: { pattern: 'foo' }, folderQueries: [{ - folder: uri.parse('file://c:/') + folder: uri.parse('file://C:/') }] }; result.add([{ - resource: uri.parse('file:///c:/foo'), + resource: uri.parse('file:///C:/foo'), results: [{ preview: { text: 'bar', @@ -72,8 +72,8 @@ suite('Search - Viewlet', () => { const fileMatch = result.matches()[0]; const lineMatch = fileMatch.matches()[0]; - assert.strictEqual(fileMatch.id(), 'file:///c%3A/foo'); - assert.strictEqual(lineMatch.id(), 'file:///c%3A/foo>[2,1 -> 2,2]b'); + assert.strictEqual(fileMatch.id(), 'file:///C%3A/foo'); + assert.strictEqual(lineMatch.id(), 'file:///C%3A/foo>[2,1 -> 2,2]b'); }); test('Comparer', () => { diff --git a/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkOpeners.test.ts b/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkOpeners.test.ts index aa801c53f36ab..f9422244134ca 100644 --- a/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkOpeners.test.ts +++ b/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkOpeners.test.ts @@ -272,7 +272,7 @@ suite('Workbench - TerminalLinkOpeners', () => { type: TerminalBuiltinLinkType.Search }); deepStrictEqual(activationResult, { - link: 'file:///c%3A/Users/home/folder/file.txt', + link: 'file:///C%3A/Users/home/folder/file.txt', source: 'editor' });