on master help sign in
allow scrolling past virtual text line

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

commitd6c8e0c946d768abdb2d688cb7cd67683ac51240 authorPascal Kuthe <pascal.kuthe@semimod.de> dateWed 22 Mar 2023, 16:30 (4 years ago) parent7cf448e
1 file changed+5−4
helix-term/src/commands.rs+5−4
helix-term/src/commands.rs+5−4
@@ -1489,18 +1489,19 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
14891489 &annotations,
14901490 );
14911491
1492− let head;
1492+ let mut head;
14931493 match direction {
14941494 Forward => {
1495− head = char_idx_at_visual_offset(
1495+ let off;
1496+ (head, off) = char_idx_at_visual_offset(
14961497 doc_text,
14971498 view.offset.anchor,
14981499 (view.offset.vertical_offset + scrolloff) as isize,
14991500 0,
15001501 &text_fmt,
15011502 &annotations,
1502− )
1503− .0;
1503+ );
1504+ head += (off != 0) as usize;
15041505 if head <= cursor {
15051506 return;
15061507 }