【问题标题】:Visual Studio Code problem matcher not working with custom outputVisual Studio Code 问题匹配器不适用于自定义输出
【发布时间】:2017-12-12 14:36:31
【问题描述】:

我正在尝试让 VS Code 使用自定义输出。我创建了一个打印出来的批处理文件:

warning:main.asm(5):Something is wrong
ERROR:main.asm(2):Something else is wrong

但是当我运行以下任务时:

"tasks": [
    {
        "label": "build",
        "type": "shell",
        "command": "${workspaceFolder}\\build.bat",
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "problemMatcher":{
            "pattern":[
                {
                    "regexp": "^.*:(.*)\\(\\d+\\):(.+)$",
                    "file": 1,
                    "line": 2,
                    "message": 3,
                    "location": 0
            }]
        }
    }
]

我得到了我期望的输出,但我在问题窗口中没有得到任何错误。有什么想法吗?

【问题讨论】:

    标签: regex visual-studio-code vscode-tasks


    【解决方案1】:

    您的正则表达式 相当 不正确 - 因为 \\(\\d+\\) 周围的括号被转义,它实际上不是一个捕获组。再加上一对或括号,它对我有用:

    "regexp": "^.*:(.*)\\((\\d+)\\):(.+)$"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-09
      • 2016-07-14
      • 1970-01-01
      • 1970-01-01
      • 2015-07-23
      • 1970-01-01
      • 2021-08-10
      • 1970-01-01
      相关资源
      最近更新 更多