diff --git a/news/2 Fixes/5362.md b/news/2 Fixes/5362.md new file mode 100644 index 000000000000..11c7b02f884f --- /dev/null +++ b/news/2 Fixes/5362.md @@ -0,0 +1 @@ +Fix localhost path mappings to lowercase the drive letter on Windows. diff --git a/src/client/debugger/extension/configuration/resolvers/attach.ts b/src/client/debugger/extension/configuration/resolvers/attach.ts index 0f67c89b6b5a..6e5bd6c5ef1c 100644 --- a/src/client/debugger/extension/configuration/resolvers/attach.ts +++ b/src/client/debugger/extension/configuration/resolvers/attach.ts @@ -96,8 +96,14 @@ export class AttachConfigurationResolver extends BaseConfigurationResolver= 0) { + // If on Windows, lowercase the drive letter for path mappings. + let localRoot = workspaceFolder.fsPath; + if (this.platformService.isWindows && localRoot.match(/^[A-Z]:/)) { + localRoot = `${localRoot[0].toLowerCase()}${localRoot.substr(1)}`; + } + debugConfiguration.pathMappings!.push({ - localRoot: workspaceFolder.fsPath, + localRoot, remoteRoot: workspaceFolder.fsPath }); } diff --git a/src/test/debugger/extension/configuration/resolvers/attach.unit.test.ts b/src/test/debugger/extension/configuration/resolvers/attach.unit.test.ts index ab69b32fca3c..17850cfa5fd2 100644 --- a/src/test/debugger/extension/configuration/resolvers/attach.unit.test.ts +++ b/src/test/debugger/extension/configuration/resolvers/attach.unit.test.ts @@ -168,6 +168,38 @@ getNamesAndValues(OSType).forEach(os => { expect(pathMappings![0].localRoot).to.be.equal(workspaceFolder.uri.fsPath); expect(pathMappings![0].remoteRoot).to.be.equal(workspaceFolder.uri.fsPath); }); + + test(`Ensure drive letter is lower cased for local path mappings on Windows when host is '${host}'`, async function () { + if (os.name !== 'Windows') { + return this.skip(); + } + + const activeFile = 'xyz.py'; + const workspaceFolder = createMoqWorkspaceFolder(path.join('C:', 'Debug', 'Python_Path')); + setupActiveEditor(activeFile, PYTHON_LANGUAGE); + const defaultWorkspace = path.join('usr', 'desktop'); + setupWorkspaces([defaultWorkspace]); + + const localRoot = `Debug_PythonPath_${new Date().toString()}`; + const debugConfig = await debugProvider.resolveDebugConfiguration!(workspaceFolder, { localRoot, host, request: 'attach' } as any as DebugConfiguration); + const pathMappings = (debugConfig as AttachRequestArguments).pathMappings; + const lowercasedLocalRoot = workspaceFolder.uri.fsPath.charAt(0).toLowerCase() + workspaceFolder.uri.fsPath.substr(1); + + expect(pathMappings![0].localRoot).to.be.equal(lowercasedLocalRoot); + }); + test(`Ensure local path mappings are not modified when not pointing to a local drive when host is '${host}'`, async () => { + const activeFile = 'xyz.py'; + const workspaceFolder = createMoqWorkspaceFolder(path.join('Server', 'Debug', 'Python_Path')); + setupActiveEditor(activeFile, PYTHON_LANGUAGE); + const defaultWorkspace = path.join('usr', 'desktop'); + setupWorkspaces([defaultWorkspace]); + + const localRoot = `Debug_PythonPath_${new Date().toString()}`; + const debugConfig = await debugProvider.resolveDebugConfiguration!(workspaceFolder, { localRoot, host, request: 'attach' } as any as DebugConfiguration); + const pathMappings = (debugConfig as AttachRequestArguments).pathMappings; + + expect(pathMappings![0].localRoot).to.be.equal(workspaceFolder.uri.fsPath); + }); }); ['192.168.1.123', 'don.debugger.com'].forEach(host => { test(`Ensure path mappings are not automatically added when host is '${host}'`, async () => {