Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure using request: launch item in launch.json for debugging sends pathmappings #5552

Merged
merged 5 commits into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from 4 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/3568.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Using "request": "launch" item in launch.json for debugging sends pathMappings
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,36 @@
"description": "Debug port (default is 0, resulting in the use of a dynamic port).",
"default": 0
},
"pathMappings": {
karrtikr marked this conversation as resolved.
Show resolved Hide resolved
"type": "array",
"label": "Path mappings.",
"items": {
"type": "object",
"label": "Path mapping",
"required": [
"localRoot",
"remoteRoot"
],
"properties": {
"localRoot": {
"type": "string",
"label": "Local source root.",
"default": "${workspaceFolder}"
},
"remoteRoot": {
"type": "string",
"label": "Remote source root.",
"default": "."
}
}
},
"default": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
}
]
},
"host": {
"type": "string",
"description": "IP address of the of the local debug server (default is localhost).",
Expand Down
13 changes: 13 additions & 0 deletions src/client/debugger/extension/configuration/resolvers/launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,19 @@ export class LaunchConfigurationResolver extends BaseConfigurationResolver<Launc
if (debugConfiguration.pyramid) {
debugConfiguration.program = (await this.configurationProviderUtils.getPyramidStartupScriptFilePath(workspaceFolder))!;
}
if (!debugConfiguration.pathMappings) {
debugConfiguration.pathMappings = workspaceFolder ? [{
localRoot: workspaceFolder.fsPath,
remoteRoot: '.'
}] : [];
}
// This is for backwards compatibility.
if (debugConfiguration.localRoot && debugConfiguration.remoteRoot) {
debugConfiguration.pathMappings!.push({
localRoot: debugConfiguration.localRoot,
remoteRoot: debugConfiguration.remoteRoot
});
}
this.sendTelemetry(
debugConfiguration.request as 'launch' | 'test',
debugConfiguration
Expand Down
6 changes: 3 additions & 3 deletions src/client/debugger/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ interface ICommonDebugArguments {
// Show return values of functions while stepping.
showReturnValue?: boolean;
subProcess?: boolean;
}
export interface IKnownAttachDebugArguments extends ICommonDebugArguments {
workspaceFolder?: string;
// An absolute path to local directory with source.
localRoot?: string;
remoteRoot?: string;
pathMappings?: { localRoot: string; remoteRoot: string }[];
}
export interface IKnownAttachDebugArguments extends ICommonDebugArguments {
workspaceFolder?: string;
customDebugger?: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,16 @@ suite('Debugging - Config Resolver Launch', () => {
expect(debugConfig).to.have.property('justMyCode', testParams.expectedResult);
});
});
test('Ensure pathMappings property is correctly derived', async () => {
const pythonPath = `PythonPath_${new Date().toString()}`;
const workspaceFolder = createMoqWorkspaceFolder(__dirname);
const pythonFile = 'xyz.py';
setupIoc(pythonPath);
setupActiveEditor(pythonFile, PYTHON_LANGUAGE);
const debugConfig = await debugProvider.resolveDebugConfiguration!(workspaceFolder, { localRoot: 'abc', remoteRoot: 'remoteabc' } as LaunchRequestArguments);
expect(debugConfig).to.have.property('pathMappings');
expect(debugConfig!.pathMappings).to.deep.equal([{ localRoot: workspaceFolder.uri.fsPath, remoteRoot: '.' }, { localRoot: 'abc', remoteRoot: 'remoteabc' }]);
});
async function testFixFilePathCase(isWindows: boolean, isMac: boolean, isLinux: boolean) {
const pythonPath = `PythonPath_${new Date().toString()}`;
const workspaceFolder = createMoqWorkspaceFolder(__dirname);
Expand Down
Loading