Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2 Fixes/5362.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix localhost path mappings to lowercase the drive letter on Windows.
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,14 @@ export class AttachConfigurationResolver extends BaseConfigurationResolver<Attac
if (workspaceFolder && debugConfiguration.host &&
debugConfiguration.pathMappings!.length === 0 &&
['LOCALHOST', '127.0.0.1', '::1'].indexOf(debugConfiguration.host.toUpperCase()) >= 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
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down