Skip to content

Commit d7b67c0

Browse files
Use consoleName in launch.json file (#319)
* Add consoleName as arg * Update consoleName before sent it to debugpy * Add tests * Fix lint * Show variables in hex (#317) * Add debug Visualizer * Add proposal * add hex view * fux lint * fix lint * Add localization, move tree creation to own file * fix compile errors
1 parent 0f507f3 commit d7b67c0

File tree

5 files changed

+53
-4
lines changed

5 files changed

+53
-4
lines changed

package.json

+10-4
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,11 @@
264264
"default": false,
265265
"description": "Whether to enable Sub Process debugging",
266266
"type": "boolean"
267+
},
268+
"consoleName": {
269+
"default": "Python Debug Console",
270+
"description": "Display name of the debug console or terminal",
271+
"type": "string"
267272
}
268273
}
269274
},
@@ -336,10 +341,6 @@
336341
"internalConsole"
337342
]
338343
},
339-
"consoleTitle": {
340-
"default": "Python Debug Console",
341-
"description": "Display name of the debug console or terminal"
342-
},
343344
"cwd": {
344345
"default": "${workspaceFolder}",
345346
"description": "Absolute path to the working directory of the program being debugged. Default is the root directory of the file (leave empty).",
@@ -493,6 +494,11 @@
493494
"default": "matplotlib",
494495
"description": "The GUI event loop that's going to run. Possible values: \"matplotlib\", \"wx\", \"qt\", \"none\", or a custom function that'll be imported and run.",
495496
"type": "string"
497+
},
498+
"consoleName": {
499+
"default": "Python Debug Console",
500+
"description": "Display name of the debug console or terminal",
501+
"type": "string"
496502
}
497503
}
498504
}

src/extension/debugger/configuration/resolvers/base.ts

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ export abstract class BaseConfigurationResolver<T extends DebugConfiguration>
4141
if (debugConfiguration.clientOS === undefined) {
4242
debugConfiguration.clientOS = getOSType() === OSType.Windows ? 'windows' : 'unix';
4343
}
44+
if (debugConfiguration.consoleName) {
45+
debugConfiguration.consoleTitle = debugConfiguration.consoleName;
46+
delete debugConfiguration.consoleName;
47+
}
4448
return debugConfiguration as T;
4549
}
4650

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

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ export class LaunchConfigurationResolver extends BaseConfigurationResolver<Launc
3939
if (debugConfiguration.clientOS === undefined) {
4040
debugConfiguration.clientOS = getOSType() === OSType.Windows ? 'windows' : 'unix';
4141
}
42+
if (debugConfiguration.consoleName) {
43+
debugConfiguration.consoleTitle = debugConfiguration.consoleName;
44+
delete debugConfiguration.consoleName;
45+
}
4246
return debugConfiguration;
4347
}
4448

src/test/unittest/configuration/resolvers/attach.unit.test.ts

+20
Original file line numberDiff line numberDiff line change
@@ -565,5 +565,25 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
565565
expect(debugConfig).to.have.property('justMyCode', testParams.expectedResult);
566566
});
567567
});
568+
569+
test('Send consoleName value to debugpy as consoleTitle', async () => {
570+
const activeFile = 'xyz.py';
571+
const consoleName = 'My Console Name';
572+
const workspaceFolder = createMoqWorkspaceFolder(__dirname);
573+
setupActiveEditor(activeFile, PYTHON_LANGUAGE);
574+
const defaultWorkspace = path.join('usr', 'desktop');
575+
setupWorkspaces([defaultWorkspace]);
576+
577+
const debugOptions = debugOptionsAvailable
578+
.slice()
579+
.concat(DebugOptions.Jinja, DebugOptions.Sudo) as DebugOptions[];
580+
581+
const debugConfig = await resolveDebugConfiguration(workspaceFolder, {
582+
...attach,
583+
debugOptions,
584+
consoleName,
585+
});
586+
expect(debugConfig).to.have.property('consoleTitle', consoleName);
587+
});
568588
});
569589
});

src/test/unittest/configuration/resolvers/launch.unit.test.ts

+15
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,21 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
953953
});
954954
});
955955

956+
test('Send consoleName value to debugpy as consoleTitle', async () => {
957+
const consoleName = 'My Console Name';
958+
const pythonPath = `PythonPath_${new Date().toString()}`;
959+
const workspaceFolder = createMoqWorkspaceFolder(__dirname);
960+
const pythonFile = 'xyz.py';
961+
setupIoc(pythonPath);
962+
setupActiveEditor(pythonFile, PYTHON_LANGUAGE);
963+
964+
const debugConfig = await resolveDebugConfiguration(workspaceFolder, {
965+
...launch,
966+
...{ consoleName },
967+
});
968+
expect(debugConfig).to.have.property('consoleTitle', consoleName);
969+
});
970+
956971
async function testSetting(
957972
requestType: 'launch' | 'attach',
958973
settings: Record<string, boolean>,

0 commit comments

Comments
 (0)