diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 08ba27820..1f0d0cd17 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -10,6 +10,7 @@ Deprecations and removed features Interactive improvements ------------------------ - :doc:`prompt_pwd ` now strips control characters. +- Repaint events (as triggered by changes to color variables or event handlers running ``commandline -f repaint``) no longer reset the completion pager and other transient UI states (:issue:`12683`). - Background color and underline color specified in :envvar:`fish_color_valid_path` are now respected (:issue:`12622`). Improved terminal support diff --git a/src/reader/reader.rs b/src/reader/reader.rs index d7bd38996..a8ab5394d 100644 --- a/src/reader/reader.rs +++ b/src/reader/reader.rs @@ -1154,9 +1154,9 @@ pub fn reader_execute_readline_cmd(parser: &Parser, ch: CharEvent) { if matches!( readline_cmd_evt.cmd, ReadlineCmd::ClearScreenAndRepaint + | ReadlineCmd::ForceRepaint | ReadlineCmd::RepaintMode | ReadlineCmd::Repaint - | ReadlineCmd::ForceRepaint ) { data.queued_repaint = true; } @@ -2847,7 +2847,9 @@ fn handle_char_event(&mut self, injected_event: Option) -> ControlFlo self.command_line_transient_edit = None; } - self.rls_mut().last_cmd = Some(readline_cmd); + if !command_only_affects_rendering(readline_cmd) { + self.rls_mut().last_cmd = Some(readline_cmd); + } } CharEvent::Command(command) => { self.run_input_command_scripts(&command); @@ -6291,6 +6293,15 @@ fn command_ends_history_search(c: ReadlineCmd) -> bool { ) } +fn command_only_affects_rendering(c: ReadlineCmd) -> bool { + #[allow(non_camel_case_types)] + type rl = ReadlineCmd; + matches!( + c, + rl::ClearScreenAndRepaint | rl::ForceRepaint | rl::RepaintMode | rl::Repaint + ) +} + /// Return true if we believe ourselves to be orphaned. loop_count is how many times we've tried to /// stop ourselves via SIGGTIN. fn check_for_orphaned_process(loop_count: usize, shell_pgid: libc::pid_t) -> bool { diff --git a/tests/checks/tmux-repaint.fish b/tests/checks/tmux-repaint.fish index ba565352f..564db49d5 100644 --- a/tests/checks/tmux-repaint.fish +++ b/tests/checks/tmux-repaint.fish @@ -20,6 +20,7 @@ isolated-tmux-start -C ' 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" + bind ctrl-g,R repaint ' isolated-tmux capture-pane -p @@ -45,3 +46,14 @@ isolated-tmux send-keys C-g G tmux-sleep isolated-tmux capture-pane -p # CHECK: 5> + +isolated-tmux send-keys status Space Tab C-g R Tab +tmux-sleep +isolated-tmux capture-pane -p | sed 2q +# CHECK: 6> status +# CHECK: basename (Print the file name (without the path) of the currently running scr…) +isolated-tmux send-keys C-g R Tab +tmux-sleep +isolated-tmux capture-pane -p | sed 2q +# CHECK: 7> status basename +# CHECK: basename (Print the file name (without the path) of the currently running scr…)