microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.64k stars 29.04k forks source link

PROMPT_COMMAND breaks VSC's launch/debugger #142585

Closed working-name closed 2 years ago

working-name commented 2 years ago

Issue Type: Bug

If I want to be able to duplicate tabs and maintain the previous path while utilizing Windows Terminal Preview, I have to get a custom PROMPT_COMMAND in there, but that unfortunately breaks launching things with node-terminal. So no more debugging :(

How can I make the two work together?

What I went with but would like to know if there's something smarter:

if [[ -z $VSCODE_INSPECTOR_OPTIONS ]]; then
    PROMPT_COMMAND=${PROMPT_COMMAND:+"$PROMPT_COMMAND; "}'printf "\e]9;9;%s\e\\" "$(wslpath -w "$PWD")"'
fi

Here's the line: PROMPT_COMMAND=${PROMPT_COMMAND:+"$PROMPT_COMMAND; "}'printf "\e]9;9;%s\e\\" "$(wslpath -w "$PWD")"'

VS Code version: Code 1.64.1 (d6ee99e4c045a6716e5c653d7da8e9ae6f5a8b03, 2022-02-07T17:16:22.147Z) OS version: Windows_NT x64 10.0.22000 Restricted Mode: No Remote OS version: Linux x64 5.10.60.1-microsoft-standard-WSL2 Remote OS version: Linux x64 5.10.60.1-microsoft-standard-WSL2

Extensions (64) Extension|Author (truncated)|Version ---|---|--- better-comments|aar|2.1.0 jsx-html-tags|ang|1.0.0 vscode-toggle-quotes|Bri|0.3.6 es7-react-js-snippets|dsz|4.3.1 file-icons|fil|1.0.29 dotenv|mik|1.0.1 vscode-apache|mrm|1.2.0 remote-containers|ms-|0.217.1 remote-ssh|ms-|0.70.0 remote-ssh-edit|ms-|0.70.0 remote-wsl|ms-|0.64.2 vscode-remote-extensionpack|ms-|0.21.0 debugger-for-chrome|msj|4.13.0 php-docblocker|nei|2.6.1 material-icon-theme|PKi|4.12.1 vscode-sqlite|ale|0.14.0 bootstrap5-vscode|Anb|0.2.2 unique-lines|bib|1.0.0 vscode-intelephense-client|bme|1.8.0 npm-intellisense|chr|1.4.0 path-intellisense|chr|2.7.0 jshint|dba|0.11.0 vscode-eslint|dba|2.2.2 quicktype-refresh|dog|0.1.1 parameter-hints|Dom|0.2.7 gitlens|eam|11.7.0 vscode-html-css|ecm|1.11.0 prettier-vscode|esb|9.2.0 vscode-diff|fab|1.4.2 shell-format|fox|7.2.2 vscode-pull-request-github|Git|0.36.0 go|gol|0.31.0 todo-tree|Gru|0.0.215 beautify|Hoo|1.5.0 phpcs|ika|1.0.5 bracket-peek|jom|1.4.2 minifyall|jos|2.10.0 autodocblocker|mad|1.0.2 bash-ide-vscode|mad|1.11.0 rainbow-csv|mec|2.0.0 mongodb-vscode|mon|0.8.0 vscode-docker|ms-|1.19.0 vsliveshare|ms-|1.0.5330 indent-rainbow|ode|8.2.2 fix-json|oli|0.1.2 docthis|oou|0.8.2 paste-and-indent|par|0.1.0 vscode-phpcbf|per|0.0.8 text-power-tools|qcz|1.30.0 format-html-in-php|rif|1.7.0 bash-debug|rog|0.3.9 partial-diff|ryu|1.4.3 preview-vscode|sea|2.2.5 vscode-fileutils|sle|3.5.0 tabnine-vscode|Tab|3.5.24 html-preview-vscode|tht|0.2.5 shellcheck|tim|0.18.6 duplicate-finder|tle|0.0.6 sort-lines|Tyr|1.9.1 es-quotes|vil|0.2.6 vscodeintellicode|Vis|1.2.17 better-align|wwm|1.1.6 php-debug|xde|1.23.0 markdown-all-in-one|yzh|3.4.0 (4 theme extensions excluded)
Tyriar commented 2 years ago

@working-name do you mean your workaround works because it looks fine to me? Can you clarify what you mean by "node-terminal"?

working-name commented 2 years ago

Hi @Tyriar,

Yes the workaround works, was just wondering if there's a better way than assuming that particular variable is present.

As part of launch.json, a configuration to debug a node app might look like this:

        {
            "name": "Next.js: debug server-side",
            "type": "node-terminal",
            "request": "launch",
            "command": "npm run dev"
        }

The type there is what I was referring to. You can have a regular terminal open up in vscode and that will not set VSCODE_INSPECTOR_OPTIONS from my limited testing.

Tyriar commented 2 years ago

Ok, I guess this is more of a debug question then. @connor4312 The 9;9 sequence above is required by WT, is there a way to make this in $PROMPT_COMMAND play nicely with debugging?

connor4312 commented 2 years ago

Adding that PROMPT_COMMAND in my WSL doesn't cause issues. In what way does it break node-terminal?

/gifPlease

working-name commented 2 years ago

@connor4312 Not sure what's up but I cannot reproduce it 😞

What it did do is simply echo the command text at the top, and then drop me to a prompt. The command would not run at all however. I changed the command to echo hi it would print echo hi right above the prompt, and then drop me to the prompt as well. Nothing further.

image

connor4312 commented 2 years ago

@Tyriar js-debug immediately uses terminal.sendText to issue the command. Is there something different we should be doing for this case?

Tyriar commented 2 years ago

Is something running in the terminal capturing the command being sent maybe? This seems like a good case for why we added the automation shell.