microsoft / vscode

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

Shell integration breaks prompt when using Fish shell with Tide prompt #187185

Open jaminthorns opened 1 year ago

jaminthorns commented 1 year ago

Steps to Reproduce

  1. Set Fish as the default shell for your system.
  2. Install the Tide prompt.
  3. Observe broken prompt and error messages when starting an integrated terminal:

    fish: Unknown command: '_tide_item_pwd git'
    ~/.config/fish/functions/_tide_1_line_prompt.fish (line 4): 
          _tide_item_$item
          ^~~~~~~~~~~~~~~^
    in function '_tide_1_line_prompt'
    in command substitution
    fish: Unknown command: '_tide_item_status cmd_duration context jobs'
    ~/.config/fish/functions/_tide_1_line_prompt.fish (line 11): 
          _tide_item_$item
          ^~~~~~~~~~~~~~~^
    in function '_tide_1_line_prompt'
    in command substitution

Screenshots

andyearnshaw commented 1 year ago

It looks like this was caused by #185355 and has broken prompts that rely on variables local to the file that declares the fish prompt function. It's simple enough to reproduce with the following fish_prompt.fish file:

set TEST hello

function fish_prompt
    echo $TEST
end

Now, in settings, disable Terminal › Integrated › Shell Integration: Enabled. Create a new terminal window and you should see "hello" as the prompt. Enable shell integration once more and create another new terminal window, the prompt will now be blank.

EDIT: Specifically, it's copying the fish_prompt function that breaks the link to the local variables. From the man pages:

Copying a function using -c copies only the body of the function, and does not attach any event notifications from the original function.

This implies to me that a new function is created using the function source text, and it's not copying a reference like you might expect as a JavaScript developer. I think #185355 may need reverting.

I've tested this and can confirm it's not the case. So something else is going on and that needs a deeper dive than I can spare time for right now.

Drew-Daniels commented 1 year ago

Yep same issue here

kaysond commented 1 year ago

Same issue, though in my case I'm seeing an extra newline at the end of the prompt. https://github.com/IlanCosman/tide/issues/433

macintacos commented 6 months ago

Just to add to this, I use Hydro and just noticed that I am encountering this problem. Disabling the shell integration works.