aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/lib.rs
diff options
context:
space:
mode:
authorPascal Kuthe2023-03-06 15:25:41 +0000
committerBlaž Hrastnik2023-03-27 00:54:40 +0000
commit72b93116784ec944f49c7f6a335b0aa663f1430e (patch)
treecee2a5ceac008625f5bd749eb634fbbdaf89d951 /helix-core/src/lib.rs
parent0ab96cc2576cf8d78d54bcc42e0e7f5285321030 (diff)
fix view anchors not at start of a visual line
The top of a view is marked by a char idx anchor. That char idx is usually the first character of the visual line it's on. We use a char index instead of a line index because the view may start in the middle of a line with soft wrapping. However, it's possible to temporarily endup in a state where this anchor is not the first character of the first visual line. This is pretty rare because edits usually happen inside/after the view. In most cases we handle this case correctly. However, if the cursor is before the anchor (but still in view) there can be crashes or visual artifacts. This is caused by the fact that visual_offset_from_anchor (and the positioning code in view.rs) incorrectly assumed that the (cursor) position is always after the view anchor if the cursor is in view. But if the anchor is not the first character of the first visual line this is not the case anymore. In that case crashes and visual artifacts are possible. This commit fixes that problem by changing `visual_offset_from_anchor` (and callsites) to properly consider that case.
Diffstat (limited to 'helix-core/src/lib.rs')
-rw-r--r--helix-core/src/lib.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/helix-core/src/lib.rs b/helix-core/src/lib.rs
index e3f862a6..4d50e48b 100644
--- a/helix-core/src/lib.rs
+++ b/helix-core/src/lib.rs
@@ -98,7 +98,7 @@ pub use {regex, tree_sitter};
pub use graphemes::RopeGraphemes;
pub use position::{
char_idx_at_visual_offset, coords_at_pos, pos_at_coords, visual_offset_from_anchor,
- visual_offset_from_block, Position,
+ visual_offset_from_block, Position, VisualOffsetError,
};
#[allow(deprecated)]
pub use position::{pos_at_visual_coords, visual_coords_at_pos};