Skip to content

Commit 8b5ed99

Browse files
committed
get it to work - with logs
1 parent 843cf0a commit 8b5ed99

File tree

1 file changed

+46
-40
lines changed

1 file changed

+46
-40
lines changed

src/vs/workbench/contrib/terminal/browser/media/fish_xdg_data/fish/vendor_conf.d/shellIntegration.fish

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -99,26 +99,32 @@ function __vsc_cmd_clear --on-event fish_cancel
9999
end
100100
101101
# Preserve the user's existing prompt, to wrap in our escape sequences.
102-
function init_vscode_shell_integration
103-
functions --copy fish_prompt __vsc_fish_prompt
104-
functions --erase init_vscode_shell_integration
105-
end
102+
function init_vscode_shell_integration --on-event fish_prompt
103+
if functions --query fish_prompt
104+
if functions --query __vsc_fish_prompt
105+
functions --erase __vsc_fish_prompt
106+
end
107+
echo "setting __vsc_fish_prompt to actual fish prompt"
108+
functions --copy fish_prompt __vsc_fish_prompt
109+
functions --erase init_vscode_shell_integration
110+
_mode_prompt
111+
else
112+
if functions --query __vsc_fish_prompt
113+
functions --erase init_vscode_shell_integration
114+
_mode_prompt
115+
else
116+
echo "setting __vsc_fish_prompt to fallback fish prompt"
117+
function __vsc_fish_prompt
118+
echo -n (whoami)@(prompt_hostname) (prompt_pwd) '~> '
119+
end
120+
end
121+
end
122+
end
123+
init_vscode_shell_integration
106124

107125
# Sent whenever a new fish prompt is about to be displayed.
108126
# Updates the current working directory.
109127
function __vsc_update_cwd --on-event fish_prompt
110-
if type -q init_vscode_shell_integration
111-
// TODO: this assumes our og one is set first, maybe add an else case for when that's not true?
112-
if functions -q __vsc_fish_prompt_og fish_prompt
113-
set func1 (functions -a __vsc_fish_prompt_og)
114-
set func2 (functions -a fish_prompt)
115-
if test "$func1" != "$func2"
116-
// if fish prompt is defined and is not equal to the one we've set, then init the user's one
117-
init_vscode_shell_integration
118-
end
119-
end
120-
end
121-
122128
__vsc_esc P Cwd=(__vsc_escape_value "$PWD")
123129

124130
# If a command marker exists, remove it.
@@ -149,29 +155,29 @@ end
149155
# Preserve and wrap fish_mode_prompt (which appears to the left of the regular
150156
# prompt), but only if it's not defined as an empty function (which is the
151157
# officially documented way to disable that feature).
152-
if __vsc_fish_has_mode_prompt
153-
functions --copy fish_mode_prompt __vsc_fish_mode_prompt
154-
155-
function fish_mode_prompt
156-
__vsc_fish_prompt_start
157-
__vsc_fish_mode_prompt
158-
end
159-
160-
function fish_prompt
161-
if set -q __vsc_fish_prompt
162-
__vsc_fish_prompt
163-
end
164-
__vsc_fish_cmd_start
165-
end
166-
functions --copy fish_prompt __vsc_fish_prompt_og
167-
else
158+
function _mode_prompt
159+
if __vsc_fish_has_mode_prompt
160+
functions --copy fish_mode_prompt __vsc_fish_mode_prompt
161+
162+
function fish_mode_prompt
163+
__vsc_fish_prompt_start
164+
__vsc_fish_mode_prompt
165+
end
166+
167+
function fish_prompt
168+
__vsc_fish_prompt
169+
__vsc_fish_cmd_start
170+
end
171+
set func2 (functions -a fish_prompt)
172+
echo "set fish prompt to $func2"
173+
else
168174
# No fish_mode_prompt, so put everything in fish_prompt.
169-
function fish_prompt
170-
__vsc_fish_prompt_start
171-
if set -q __vsc_fish_prompt
172-
__vsc_fish_prompt
173-
end
174-
__vsc_fish_cmd_start
175-
end
176-
functions --copy fish_prompt __vsc_fish_prompt_og
175+
function fish_prompt
176+
__vsc_fish_prompt_start
177+
__vsc_fish_prompt
178+
__vsc_fish_cmd_start
179+
end
180+
set func2 (functions -a fish_prompt)
181+
echo "set fish prompt to $func2"
182+
end
177183
end

0 commit comments

Comments
 (0)