microsoft / microsoft/vscode-java-debug

Escape does not cancel a launch that uses command:SpecifyProgramArgs

未关闭
#1,450 2 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@testforstephen 已经在做这个了。

开始于 2024年2月28日。

ai-triaged bug
主要语言
TypeScript
星标
591
派生
429
平均合并
1 天 9 小时
30 天内合并 PR
19

描述

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.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。