Skip to content

Commit

Permalink
Ensure using request: launch item in launch.json for debugging sends …
Browse files Browse the repository at this point in the history
…pathmappings (#5552)

* Ensure using request: launch item in launch.json for debugging sends pathMappings
* News entry
* Addressed reviews
* Resolved tests
* Reverted p[ackage.json
  • Loading branch information
Kartik Raj authored and DonJayamanne committed May 21, 2019
1 parent f2cb9c9 commit 1fad96f
Show file tree
Hide file tree
Showing 5 changed files with 284 additions and 247 deletions.
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
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

0 comments on commit 1fad96f

Please sign in to comment.