Skip to content

Commit 1fad96f

Browse files
Kartik RajDonJayamanne
authored andcommitted
Ensure using request: launch item in launch.json for debugging sends pathmappings (microsoft#5552)
* Ensure using request: launch item in launch.json for debugging sends pathMappings * News entry * Addressed reviews * Resolved tests * Reverted p[ackage.json
1 parent f2cb9c9 commit 1fad96f

File tree

5 files changed

+284
-247
lines changed

5 files changed

+284
-247
lines changed

news/2 Fixes/3568.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Using "request": "launch" item in launch.json for debugging sends pathMappings

src/client/debugger/extension/configuration/resolvers/launch.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,19 @@ export class LaunchConfigurationResolver extends BaseConfigurationResolver<Launc
122122
if (debugConfiguration.pyramid) {
123123
debugConfiguration.program = (await this.configurationProviderUtils.getPyramidStartupScriptFilePath(workspaceFolder))!;
124124
}
125+
if (!debugConfiguration.pathMappings) {
126+
debugConfiguration.pathMappings = workspaceFolder ? [{
127+
localRoot: workspaceFolder.fsPath,
128+
remoteRoot: '.'
129+
}] : [];
130+
}
131+
// This is for backwards compatibility.
132+
if (debugConfiguration.localRoot && debugConfiguration.remoteRoot) {
133+
debugConfiguration.pathMappings!.push({
134+
localRoot: debugConfiguration.localRoot,
135+
remoteRoot: debugConfiguration.remoteRoot
136+
});
137+
}
125138
this.sendTelemetry(
126139
debugConfiguration.request as 'launch' | 'test',
127140
debugConfiguration

src/client/debugger/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ interface ICommonDebugArguments {
3636
// Show return values of functions while stepping.
3737
showReturnValue?: boolean;
3838
subProcess?: boolean;
39-
}
40-
export interface IKnownAttachDebugArguments extends ICommonDebugArguments {
41-
workspaceFolder?: string;
4239
// An absolute path to local directory with source.
4340
localRoot?: string;
4441
remoteRoot?: string;
4542
pathMappings?: { localRoot: string; remoteRoot: string }[];
43+
}
44+
export interface IKnownAttachDebugArguments extends ICommonDebugArguments {
45+
workspaceFolder?: string;
4646
customDebugger?: boolean;
4747
}
4848

src/test/debugger/extension/configuration/resolvers/launch.unit.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,16 @@ suite('Debugging - Config Resolver Launch', () => {
373373
expect(debugConfig).to.have.property('justMyCode', testParams.expectedResult);
374374
});
375375
});
376+
test('Ensure pathMappings property is correctly derived', async () => {
377+
const pythonPath = `PythonPath_${new Date().toString()}`;
378+
const workspaceFolder = createMoqWorkspaceFolder(__dirname);
379+
const pythonFile = 'xyz.py';
380+
setupIoc(pythonPath);
381+
setupActiveEditor(pythonFile, PYTHON_LANGUAGE);
382+
const debugConfig = await debugProvider.resolveDebugConfiguration!(workspaceFolder, { localRoot: 'abc', remoteRoot: 'remoteabc' } as LaunchRequestArguments);
383+
expect(debugConfig).to.have.property('pathMappings');
384+
expect(debugConfig!.pathMappings).to.deep.equal([{ localRoot: workspaceFolder.uri.fsPath, remoteRoot: '.' }, { localRoot: 'abc', remoteRoot: 'remoteabc' }]);
385+
});
376386
async function testFixFilePathCase(isWindows: boolean, isMac: boolean, isLinux: boolean) {
377387
const pythonPath = `PythonPath_${new Date().toString()}`;
378388
const workspaceFolder = createMoqWorkspaceFolder(__dirname);

0 commit comments

Comments
 (0)