From dd4c04e2ff8c11a35ca2f0d82ab1bf3f671603e9 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 4 May 2025 12:25:20 +0200 Subject: [PATCH] Fix empty soft-wrapped line not being removed before execution Commit 7acc2b7 added an empty line to our screen representation if we are wrapped. This regressed the fix for #6826. In the attached test case, there is a spurious empty line after the first one. Adjust the fix to remove it again. Patch-by: kerty https://github.com/fish-shell/fish-shell/pull/11153#issuecomment-2800087389 --- src/screen.rs | 8 ++++---- tests/checks/tmux-wrapping.fish | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 tests/checks/tmux-wrapping.fish diff --git a/src/screen.rs b/src/screen.rs index b5abebf0b..680bdbad3 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -756,11 +756,11 @@ pub fn save_status(&mut self) { /// Return whether we believe the cursor is wrapped onto the last line, and that line is /// otherwise empty. This includes both soft and hard wrapping. pub fn cursor_is_wrapped_to_own_line(&self) -> bool { - // Note == comparison against the line count is correct: we do not create a line just for the - // cursor. If there is a line containing the cursor, then it means that line has contents and we - // should return false. // Don't consider dumb terminals to have wrapping for the purposes of this function. - self.actual.cursor.x == 0 && self.actual.cursor.y == self.actual.line_count() && !is_dumb() + self.actual.cursor.x == 0 + && self.actual.cursor.y != 0 + && self.actual.cursor.y + 1 == self.actual.line_count() + && !is_dumb() } /// Appends a character to the end of the line that the output cursor is on. This function diff --git a/tests/checks/tmux-wrapping.fish b/tests/checks/tmux-wrapping.fish new file mode 100644 index 000000000..614f5ec51 --- /dev/null +++ b/tests/checks/tmux-wrapping.fish @@ -0,0 +1,17 @@ +#RUN: %fish %s +#REQUIRES: command -v tmux + +set -g isolated_tmux_fish_extra_args -C ' + function fish_prompt; echo \'$ \'; end + bind ctrl-g "commandline -i \'echo \'(printf %0(math \$COLUMNS - (string length \'\$ echo \'))d 0)" +' +isolated-tmux-start + +isolated-tmux send-keys C-g Enter +tmux-sleep +isolated-tmux capture-pane -p | awk 'NR <= 4 {print NR ":" $0}' + +# CHECK: 1:$ echo 0000000000000000000000000000000000000000000000000000000000000000000000000 +# CHECK: 2:0000000000000000000000000000000000000000000000000000000000000000000000000 +# CHECK: 3:$ +# CHECK: 4: