Use vscode's selected launch config for project launch and codelens run/debug #6813
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The issue solved here is that when the Project > Run|Debug (from project's context menu) or from main class' Code lenses is used, the extension does not use the vscode's selected Laucnh configuration properly.
The original code went throug all defined
java+
launch configurations and extract settings from the firstjava+
config found. So if the user intentionally selected 2nd and later config in the UI selector, Project > Run or Run codelen didn't use the parameters in there, instead of parameters from the 1st (texually) config were passed to NBLS.Sadly, vscode does not support reading the configuration selector, so it is read using a hack: a temporary
DebugConfigurationProvider
is registered, which captures thedebugConfiguration
passed to it by vscode platform - and then aborts the exetion by returningundefined
(this is permitted by API documentation). Then it uses the configuration object and overrides values with data passed to therunDebug
function.When no
java+
launch configurations are present inlaunch.json
, vscode would display a QuickPick for the user - that's why the situation is tested at the start. In that case, a simple configuration is created and used as in the original code.Since Run codelen is generated for all project configurations, the codelen needs to either
I've changed both the codelen and
runDebug
to handle that.