Skip to content

Commit

Permalink
allow scrolling past virtual text line
Browse files Browse the repository at this point in the history
Virtual text lines (either caused by softwrapped inlay hints that take
multiple or line annotations) currently block scrolling downwards.

if the visual offset passed to char_idx_at_visual_offset or
visual_offset_from_block is within a virtual text line then the char
position before the virtual text and a visual offset are returned.
We previously ignored that visual offset and as a result the cursor
would be stuck at the start of the virtual text. This commit fixes
that by simply moving the cursor to the next char (so past the virtual
text) if this visual offset is non-zero
  • Loading branch information
pascalkuthe committed Mar 25, 2023
1 parent b4cb4dd commit ec37277
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1489,18 +1489,19 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
&annotations,
);

let head;
let mut head;
match direction {
Forward => {
head = char_idx_at_visual_offset(
let off;
(head, off) = char_idx_at_visual_offset(
doc_text,
view.offset.anchor,
(view.offset.vertical_offset + scrolloff) as isize,
0,
&text_fmt,
&annotations,
)
.0;
);
head += (off != 0) as usize;
if head <= cursor {
return;
}
Expand Down

0 comments on commit ec37277

Please sign in to comment.