Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape does not cancel a launch that uses command:SpecifyProgramArgs #1450

Open
sbj42 opened this issue Feb 26, 2024 · 0 comments
Open

Escape does not cancel a launch that uses command:SpecifyProgramArgs #1450

sbj42 opened this issue Feb 26, 2024 · 0 comments
Assignees
Labels

Comments

@sbj42
Copy link
Contributor

sbj42 commented Feb 26, 2024

When launching a Java program with ${command:SpecifyProgramArgs}, the popup says that I can press 'Escape' to cancel, but it runs anyway.

Environment
  • Operating System: Windows 11
  • JDK version: 17.0.4.1
  • Visual Studio Code version: 1.86.2
  • Java extension version: 1.28.1
  • Java Debugger extension version: 17.0.4.1
Steps To Reproduce
  1. Open the repo https://github.com/sbj42/vscode-specifyprogramargs
  2. Open Test.java and press F5.
  3. Pop-up appears with "Press 'Enter' to confirm your input or 'Escape' to cancel".
  4. Press Escape.
  5. Terminal appears and runs the test program with no arguments.

See repo above, but you only need these two files:

Test.java:

public class Test {
    public static void main(String[] args) {
        System.out.println("args: " + String.join(" ", args));
    }
}

.vscode/launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "java",
            "name": "Launch with Arguments Prompt",
            "request": "launch",
            "mainClass": "",
            "args": "${command:SpecifyProgramArgs}"
        }
    ]
}

Verbose output log from "Language Support for Java": log.txt

Current Result

The debug session starts with no arguments.

Expected Result

The debug session should not start, because it was cancelled.

Additional Informations

The implementation of SpecifyProgramArgs is at extension.ts:185. When the user cancels, the function returns a string with a single space. That's indistinguishable from the user entering a space in the input.

I presume that throwing some sort of cancellation exception would be good here, for instance throw new Error('Launch cancelled'). It would be even better if the exception didn't display an error box, but I don't know enough about vscode extension command handlers to know if that's possible.

Alternatively you could just remove the "or 'Escape' to cancel" hint in the input popup.

@testforstephen testforstephen self-assigned this Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants