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 <g.kabakov@inbox.ru>
https://github.com/fish-shell/fish-shell/pull/11153#issuecomment-2800087389
This commit is contained in:
Johannes Altmanninger
2025-05-04 12:25:20 +02:00
parent 6fec5ab320
commit dd4c04e2ff
2 changed files with 21 additions and 4 deletions

View File

@@ -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

View File

@@ -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: