vscode F5 调试 C++ 代码 报错:终端将被任务重用,按任意键关闭。

调试没有任何结果输出,代码可以用Run Code运行,但是不能调试。
img

tasks.json中presentation的面板panel设置为new

g++.exe所在目录添加到系统PATH中。

task.json里

{
            "label": "g++debug",
            "type": "shell",
            "command":"g++.exe",
            "args": [
                "${file}",
                "-g",
            ]
        },

launch.json里

{
      "name": "G++ Debug",
      "type": "cppdbg",
      "preLaunchTask": "g++debug",
      "request": "launch",
      "program": "${fileDirname}/${fileBasenameNoExtension}.exe",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${fileDirname}",
      "environment": [],
      "externalConsole": true,
      "MIMode": "gdb",
      "miDebuggerPath": "gdb.exe",
      "setupCommands": [
        {
          "description": "为 gdb 启用整齐打印",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true
        }
      ]
    },