Fix regression causing off-by-one pager height on truncated autosuggestion

Commit c54131c8c5 (Make at least one character of the autosuggestion
always shown, 2025-01-26) draws autosuggetion until exactly the end
of the line, possibly truncated by an ellipsis.  The line is "barely"
soft-wrapped; no characters or cursors are on the next line.

This means that the pager can start there (on the next line).
The calculation for available pager height fails to recognize that.
Fix that.
This commit is contained in:
Johannes Altmanninger
2025-01-31 18:17:22 +01:00
parent 8ddb078db8
commit 7db955374b
2 changed files with 38 additions and 1 deletions

View File

@@ -457,7 +457,20 @@ struct ScrolledCursor {
self.desired.add_line();
}
let full_line_count = self.desired.cursor.y + calc_prompt_lines(&layout.left_prompt);
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)
{
1
} else {
0
}
+ calc_prompt_lines(&layout.left_prompt);
let pager_available_height = std::cmp::max(
1,
curr_termsize

View File

@@ -0,0 +1,24 @@
#RUN: %fish %s
#REQUIRES: command -v tmux
#REQUIRES: test -z "$CI"
set -g isolated_tmux_fish_extra_args -C '
history append ": $(string repeat $COLUMNS A)"
complete : -a \'(seq (math "$LINES * $COLUMNS"))\'
'
isolated-tmux-start
isolated-tmux send-keys : Space Tab Tab
tmux-sleep
isolated-tmux capture-pane -p
# CHECK: prompt 0> : AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA…
# 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: 8 142 276 410 544 678
# CHECK: rows 1 to 8 of 134