Skip to content

Commit f807d54

Browse files
Add a global setting to specify the default console to launch the program (#594)
* Add a global setting to specify the default console to launch the program Signed-off-by: Jinbo Wang <[email protected]> * Address review comments Signed-off-by: Jinbo Wang <[email protected]>
1 parent 58e11da commit f807d54

File tree

6 files changed

+31
-3
lines changed

6 files changed

+31
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
88
### Added
99
- Add a debug toolbar button to apply the changed classes to the running application. [#559](https://github.com/microsoft/vscode-java-debug/issues/559).
1010
- Show toString() values in Variable window and hover tooltip. [#315](https://github.com/microsoft/vscode-java-debug/issues/315), [#364](https://github.com/microsoft/vscode-java-debug/issues/364).
11+
- Add a global user setting `java.debug.settings.console` to specify the default console to launch your program. [PR#594](https://github.com/microsoft/vscode-java-debug/pull/594).
1112

1213
### Fixed:
1314
- Fix: The debug toolbar doesn't close after the program running in external terminal exits. [#582](https://github.com/microsoft/vscode-java-debug/issues/582).

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Please also check the documentation of [Language Support for Java by Red Hat](ht
5959
- `cwd` - The working directory of the program. Defaults to `${workspaceFolder}`.
6060
- `env` - The extra environment variables for the program.
6161
- `stopOnEntry` - Automatically pause the program after launching.
62-
- `console` - The specified console to launch the program. Defaults to `internalConsole`.
62+
- `console` - The specified console to launch the program. If not specified, use the console specified by the `java.debug.settings.console` user setting.
6363
- `internalConsole` - VS Code debug console (input stream not supported).
6464
- `integratedTerminal` - VS Code integrated terminal.
6565
- `externalTerminal` - External terminal that can be configured in user settings.
@@ -102,6 +102,10 @@ Please also check the documentation of [Language Support for Java by Red Hat](ht
102102
- never - Never apply the changes.
103103
- `java.debug.settings.enableRunDebugCodeLens`: enable the code lens provider for the run and debug buttons over main entry points, defaults to `true`.
104104
- `java.debug.settings.forceBuildBeforeLaunch`: force building the workspace before launching java program, defaults to `true`.
105+
- `java.debug.settings.console`: The specified console to launch Java program, defaults to `internalConsole`. If you want to customize the console for a specific debug session, please modify the 'console' config in launch.json.
106+
- `internalConsole` - VS Code debug console (input stream not supported).
107+
- `integratedTerminal` - VS Code integrated terminal.
108+
- `externalTerminal` - External terminal that can be configured in user settings.
105109

106110
## Troubleshooting
107111
Reference the [troubleshooting guide](https://github.com/Microsoft/vscode-java-debug/blob/master/Troubleshooting.md) for common errors.

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,21 @@
457457
"type": "boolean",
458458
"description": "%java.debugger.configuration.forceBuildBeforeLaunch%",
459459
"default": true
460+
},
461+
"java.debug.settings.console": {
462+
"type": "string",
463+
"enum": [
464+
"internalConsole",
465+
"integratedTerminal",
466+
"externalTerminal"
467+
],
468+
"enumDescriptions": [
469+
"%java.debugger.launch.internalConsole.description%",
470+
"%java.debugger.launch.integratedTerminal.description%",
471+
"%java.debugger.launch.externalTerminal.description%"
472+
],
473+
"description": "%java.debugger.configuration.console%",
474+
"default": "internalConsole"
460475
}
461476
}
462477
}

package.nls.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@
4444
"java.debugger.configuration.maxStringLength.description": "The maximum length of strings displayed in \"Variables\" or \"Debug Console\" viewlet, strings longer than this length will be trimmed, if 0 no trim is performed.",
4545
"java.debugger.configuration.hotCodeReplace.description": "Reload the changed Java classes during debugging. Make sure 'java.autobuild.enabled' is not disabled.",
4646
"java.debugger.configuration.enableRunDebugCodeLens.description": "Enable the run and debug code lens providers over main methods.",
47-
"java.debugger.configuration.forceBuildBeforeLaunch": "Force building the workspace before launching java program."
47+
"java.debugger.configuration.forceBuildBeforeLaunch": "Force building the workspace before launching java program.",
48+
"java.debugger.configuration.console": "The specified console to launch Java program. If you want to customize the console for a specific debug session, please modify the 'console' config in launch.json."
4849
}

package.nls.zh.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@
4444
"java.debugger.configuration.maxStringLength.description": "设定“变量”或“调试控制台”视图中显示的字符串最大长度,长度超过部分将被剪掉。如果值为0,则不执行修剪。",
4545
"java.debugger.configuration.hotCodeReplace.description": "在调试期间重新加载已更改的Java类。确保未禁用'java.autobuild.enabled'。",
4646
"java.debugger.configuration.enableRunDebugCodeLens.description": "在main方法上启用CodeLens标记。",
47-
"java.debugger.configuration.forceBuildBeforeLaunch": "在启动java程序之前强制编译整个工作空间。"
47+
"java.debugger.configuration.forceBuildBeforeLaunch": "在启动java程序之前强制编译整个工作空间。",
48+
"java.debugger.configuration.console": "指定的控制台用于启动Java程序。如果要为特定的调试会话自定义控制台,请修改launch.json中的“console”配置。"
4849
}

src/configurationProvider.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
148148
}
149149

150150
if (config.request === "launch") {
151+
// If the user doesn't specify 'console' in launch.json, use the global setting to get the launch console.
152+
if (!config.console) {
153+
const debugSettings: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("java.debug.settings");
154+
config.console = debugSettings.console;
155+
}
156+
151157
if (needsBuildWorkspace()) {
152158
try {
153159
const buildResult = await vscode.commands.executeCommand(commands.JAVA_BUILD_WORKSPACE, false);

0 commit comments

Comments
 (0)