Files
fish-shell/tests/checks/tmux-repaint.fish
Johannes Altmanninger 2b3bd29588 Fix infinite repaint when setting magic variables in prompt
Commit 7996637db5 (Make fish immediately show color changes again,
2025-12-01) repaints unnecessarily when a local unexported color
variable changes.  Also, it repaints when the change comes from
fish_prompt, causing an easy infinite loop.  Same when changing TERM,
COLORTERM and others.

This feature is relevant when using a color-theme aware theme, so
try to keep it. Repaint only on global/universal changes.
Also ignore changes if already repainting fish prompt.

This change may be at odds with concurrent execution (parser should
not care about whether we are repainting) but that's intentional
because of 1. time constraints and 2. I'm not sure what the solution
will look like; we could use the event infrastructure.  But a lot of
existing variable listeners don't use that.

Extract a context object we pass whenever we mutate the environment; While
at it, use it to pass EnvMode::USER, to reduce EnvMode responsibilities.

Fixes #12233
2025-12-30 17:20:42 +01:00

50 lines
1.3 KiB
Fish

#RUN: %fish %s
#REQUIRES: command -v tmux
isolated-tmux-start -C '
function fish_prompt
set -g counter (math $counter + 1)
set -g fish_color_status red
set -g fish_pager_color_background --background=white
echo "$counter> "
set -ga TERM .
set -ga TERMINFO .
set -ga TERMINFO_DIRS .
set -ga COLORTERM .
set -ga fish_term256 .
set -ga fish_term24bit .
end
set -eg fish_color_param
bind ctrl-g,A "{ set -l fish_color_command 111 }"
bind ctrl-g,B "set -l fish_color_command 222"
bind ctrl-g,C "set -e fish_color_command"
bind ctrl-g,D "set -eg fish_color_param"
bind ctrl-g,E "set -g fish_color_command 333"
bind ctrl-g,F "set -U fish_color_param 444"
bind ctrl-g,G "set -eg fish_color_command"
'
isolated-tmux capture-pane -p
# The weird global assignments in fish prompt cause an initial repaint.
# CHECK: 2>
isolated-tmux send-keys C-g A C-g B C-g C C-g D
tmux-sleep
isolated-tmux capture-pane -p
# CHECK: 2>
isolated-tmux send-keys C-g E
tmux-sleep
isolated-tmux capture-pane -p
# CHECK: 3>
isolated-tmux send-keys C-g F
tmux-sleep
isolated-tmux capture-pane -p
# CHECK: 4>
isolated-tmux send-keys C-g G
tmux-sleep
isolated-tmux capture-pane -p
# CHECK: 5>