Skip to content

setting "Clear before reusing" adds "c" or "cl" before debugging command in terminal on second run resulting in "command not found: c" (unable to debug twice in a row) #240953

@tcvdh

Description

@tcvdh

Does this issue occur when all extensions are disabled?: No
You will need extensions for this to work (codeLLDB in my case to start a debugging session)

  • VS Code Version: 1.97.2 (1.96.0-1.98.0)
  • OS Version: macOS 15.3

When i use the debugger (codeLLDB in this case) and i press F5, everything is fine. but when i keep the debug terminal open and i click F5 again after the first debugging session is done, it puts in "c" or "cl" before the LLDB attach command in the terminal and gives an error and doesn't start debugging.

Image

if i close the debug terminal tab and then start the debugger with F5 again it works like expected. it's only when re-running the debugger while the old debug screen is still there.
if i disable the Clear before reusing setting, it will work like expected.

"c" and "cl" are also the first few letters of "clear" so i suspect something is going on with that. (ive searched the github repo and found this, it sends "clear" to the terminal, but it prob isn't able to finish sending it to the terminal so it bugs)

if (configProvider.getConfiguration('debug.terminal').get<boolean>('clearBeforeReusing')) {
// clear terminal before reusing it
if (shell.indexOf('powershell') >= 0 || shell.indexOf('pwsh') >= 0 || shell.indexOf('cmd.exe') >= 0) {
terminal.sendText('cls');
} else if (shell.indexOf('bash') >= 0) {
terminal.sendText('clear');
} else if (platform.isWindows) {
terminal.sendText('cls');
} else {
terminal.sendText('clear');
}
}

Steps to Reproduce:
my launch.json:

{
      "name": "Debug A0 Hello",
      "type": "lldb",
      "env": {
        "ASAN_OPTIONS": "detect_leaks=0"
      },
      "request": "launch",
      "program": "a0-hello",
      "cwd": "${workspaceFolder}",
      "stopOnEntry": false,
      "preLaunchTask": "Build A0 Hello"
    },
  1. go to settings > Debug › Terminal: Clear Before Reusing and turn it ON
  2. now start the debugger F5. (without any breakpoints, so it should finish)
  3. start the debugger again without closing the Debug tab in the terminal and there should be a random "c" or "cl" (or something else) before the debugger command and fail to run.
  4. (you will also have to force quit CodeLLDB and reload vs code in order to stop the process.)

i have found some other issues and things online referencing similar problems, but those are all "resolved" or "closed" etc:

  1. Unknown characters were output in the built-in terminal. vscode-python-debugger#302 (comment) (same thing but marked as closed due to it being a "vs code" issue and not a python debugger issue)
  2. Clear terminal before launching another debuggee in terminal #116699 (the issue that led to the code referenced above being added)

Metadata

Metadata

Labels

insiders-releasedPatch has been released in VS Code Insiders

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions