diff --git a/src/screen.rs b/src/screen.rs index ad5c44ecf..3871c8f33 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -29,7 +29,7 @@ use crate::fallback::fish_wcwidth; use crate::flog::FLOGF; use crate::global_safety::RelaxedAtomicBool; -use crate::highlight::{HighlightColorResolver, HighlightSpec}; +use crate::highlight::{HighlightColorResolver, HighlightRole, HighlightSpec}; use crate::terminal::TerminalCommand::{ self, ClearToEndOfLine, ClearToEndOfScreen, CursorDown, CursorLeft, CursorMove, CursorRight, CursorUp, EnterDimMode, ExitAttributeMode, Osc133PromptStart, ScrollContentUp, @@ -457,12 +457,13 @@ struct ScrolledCursor { let full_line_count = self.desired.cursor.y - if self.desired.cursor.x == 0 - && self - .desired - .cursor - .y - .checked_sub(1) - .is_some_and(|y| self.desired.line_datas[y].is_soft_wrapped) + && self.desired.cursor.y.checked_sub(1).is_some_and(|y| { + self.desired.line_datas[y].is_soft_wrapped + && self.desired.line_datas[y] + .color_at(self.desired.line_datas[y].len() - 1) + .foreground + == HighlightRole::autosuggestion + }) { 1 } else { diff --git a/tests/checks/tmux-pager.fish b/tests/checks/tmux-pager.fish index fb00a2616..d40b62adb 100644 --- a/tests/checks/tmux-pager.fish +++ b/tests/checks/tmux-pager.fish @@ -9,6 +9,7 @@ set -g isolated_tmux_fish_extra_args -C ' isolated-tmux-start +# Check that completions don't break from truncated autosuggestion isolated-tmux send-keys : Space Tab Tab tmux-sleep isolated-tmux capture-pane -p @@ -22,3 +23,19 @@ isolated-tmux capture-pane -p # CHECK: 7 141 275 409 543 677 # CHECK: 8 142 276 410 544 678 # CHECK: rows 1 to 8 of 134 + +# Check that completions don't break than called on empty line +isolated-tmux send-keys C-u 'set fish_autosuggestion_enabled 0; function fish_prompt; string repeat (math $COLUMNS - 2) 0; end' Enter +isolated-tmux send-keys C-l : Space Tab Tab +tmux-sleep +isolated-tmux capture-pane -p +# CHECK: 000000000000000000000000000000000000000000000000000000000000000000000000000000: +# CHECK: +# CHECK: 1 135 269 403 537 671 +# CHECK: 2 136 270 404 538 672 +# CHECK: 3 137 271 405 539 673 +# CHECK: 4 138 272 406 540 674 +# CHECK: 5 139 273 407 541 675 +# CHECK: 6 140 274 408 542 676 +# CHECK: 7 141 275 409 543 677 +# CHECK: rows 1 to 7 of 134