Skip to content

Commit

Permalink
Use consoleName in launch.json file (#319)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
paulacamargo25 authored Apr 20, 2024
1 parent 0f507f3 commit d7b67c0
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 4 deletions.
14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
},
Expand Down Expand Up @@ -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).",
Expand Down Expand Up @@ -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"
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/extension/debugger/configuration/resolvers/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export abstract class BaseConfigurationResolver<T extends DebugConfiguration>
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;
}

Expand Down
4 changes: 4 additions & 0 deletions src/extension/debugger/configuration/resolvers/launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export class LaunchConfigurationResolver extends BaseConfigurationResolver<Launc
if (debugConfiguration.clientOS === undefined) {
debugConfiguration.clientOS = getOSType() === OSType.Windows ? 'windows' : 'unix';
}
if (debugConfiguration.consoleName) {
debugConfiguration.consoleTitle = debugConfiguration.consoleName;
delete debugConfiguration.consoleName;
}
return debugConfiguration;
}

Expand Down
20 changes: 20 additions & 0 deletions src/test/unittest/configuration/resolvers/attach.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,5 +565,25 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
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);
});
});
});
15 changes: 15 additions & 0 deletions src/test/unittest/configuration/resolvers/launch.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, boolean>,
Expand Down

0 comments on commit d7b67c0

Please sign in to comment.