From d7b67c0ba4636a94ded7e21afde23bf881342771 Mon Sep 17 00:00:00 2001 From: Paula Date: Sat, 20 Apr 2024 12:14:02 -0700 Subject: [PATCH] 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 --- package.json | 14 +++++++++---- .../debugger/configuration/resolvers/base.ts | 4 ++++ .../configuration/resolvers/launch.ts | 4 ++++ .../resolvers/attach.unit.test.ts | 20 +++++++++++++++++++ .../resolvers/launch.unit.test.ts | 15 ++++++++++++++ 5 files changed, 53 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index d0c4c484..0794887c 100644 --- a/package.json +++ b/package.json @@ -264,6 +264,11 @@ "default": false, "description": "Whether to enable Sub Process debugging", "type": "boolean" + }, + "consoleName": { + "default": "Python Debug Console", + "description": "Display name of the debug console or terminal", + "type": "string" } } }, @@ -336,10 +341,6 @@ "internalConsole" ] }, - "consoleTitle": { - "default": "Python Debug Console", - "description": "Display name of the debug console or terminal" - }, "cwd": { "default": "${workspaceFolder}", "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 @@ "default": "matplotlib", "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.", "type": "string" + }, + "consoleName": { + "default": "Python Debug Console", + "description": "Display name of the debug console or terminal", + "type": "string" } } } diff --git a/src/extension/debugger/configuration/resolvers/base.ts b/src/extension/debugger/configuration/resolvers/base.ts index 7775ae0d..160c6fc5 100644 --- a/src/extension/debugger/configuration/resolvers/base.ts +++ b/src/extension/debugger/configuration/resolvers/base.ts @@ -41,6 +41,10 @@ export abstract class BaseConfigurationResolver if (debugConfiguration.clientOS === undefined) { debugConfiguration.clientOS = getOSType() === OSType.Windows ? 'windows' : 'unix'; } + if (debugConfiguration.consoleName) { + debugConfiguration.consoleTitle = debugConfiguration.consoleName; + delete debugConfiguration.consoleName; + } return debugConfiguration as T; } diff --git a/src/extension/debugger/configuration/resolvers/launch.ts b/src/extension/debugger/configuration/resolvers/launch.ts index 474ba04c..423d5d9d 100644 --- a/src/extension/debugger/configuration/resolvers/launch.ts +++ b/src/extension/debugger/configuration/resolvers/launch.ts @@ -39,6 +39,10 @@ export class LaunchConfigurationResolver extends BaseConfigurationResolver { expect(debugConfig).to.have.property('justMyCode', testParams.expectedResult); }); }); + + test('Send consoleName value to debugpy as consoleTitle', async () => { + const activeFile = 'xyz.py'; + const consoleName = 'My Console Name'; + const workspaceFolder = createMoqWorkspaceFolder(__dirname); + setupActiveEditor(activeFile, PYTHON_LANGUAGE); + const defaultWorkspace = path.join('usr', 'desktop'); + setupWorkspaces([defaultWorkspace]); + + const debugOptions = debugOptionsAvailable + .slice() + .concat(DebugOptions.Jinja, DebugOptions.Sudo) as DebugOptions[]; + + const debugConfig = await resolveDebugConfiguration(workspaceFolder, { + ...attach, + debugOptions, + consoleName, + }); + expect(debugConfig).to.have.property('consoleTitle', consoleName); + }); }); }); diff --git a/src/test/unittest/configuration/resolvers/launch.unit.test.ts b/src/test/unittest/configuration/resolvers/launch.unit.test.ts index 9039781e..29c2c313 100644 --- a/src/test/unittest/configuration/resolvers/launch.unit.test.ts +++ b/src/test/unittest/configuration/resolvers/launch.unit.test.ts @@ -953,6 +953,21 @@ getInfoPerOS().forEach(([osName, osType, path]) => { }); }); + test('Send consoleName value to debugpy as consoleTitle', async () => { + const consoleName = 'My Console Name'; + const pythonPath = `PythonPath_${new Date().toString()}`; + const workspaceFolder = createMoqWorkspaceFolder(__dirname); + const pythonFile = 'xyz.py'; + setupIoc(pythonPath); + setupActiveEditor(pythonFile, PYTHON_LANGUAGE); + + const debugConfig = await resolveDebugConfiguration(workspaceFolder, { + ...launch, + ...{ consoleName }, + }); + expect(debugConfig).to.have.property('consoleTitle', consoleName); + }); + async function testSetting( requestType: 'launch' | 'attach', settings: Record,