aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/position.rs
diff options
context:
space:
mode:
authorNathan Vegdahl2021-07-06 01:58:33 +0000
committerNathan Vegdahl2021-07-06 01:58:33 +0000
commit6e15c9b8745e9708ee5271c8701d41a8393cb038 (patch)
tree1d82bb2320020d6a6a2b893db69e5bc9f3e5256d /helix-core/src/position.rs
parent28d2d6880462509f0d3131eb2eb928bb8859e058 (diff)
Make vertical selection movement work properly.
Diffstat (limited to 'helix-core/src/position.rs')
-rw-r--r--helix-core/src/position.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/helix-core/src/position.rs b/helix-core/src/position.rs
index 3d114b52..c4e8c9d6 100644
--- a/helix-core/src/position.rs
+++ b/helix-core/src/position.rs
@@ -53,6 +53,8 @@ impl From<Position> for tree_sitter::Point {
}
/// Convert a character index to (line, column) coordinates.
pub fn coords_at_pos(text: RopeSlice, pos: usize) -> Position {
+ // TODO: this isn't correct. This needs to work in terms of
+ // visual horizontal position, not graphemes.
let line = text.char_to_line(pos);
let line_start = text.line_to_char(line);
let col = RopeGraphemes::new(text.slice(line_start..pos)).count();
@@ -61,6 +63,8 @@ pub fn coords_at_pos(text: RopeSlice, pos: usize) -> Position {
/// Convert (line, column) coordinates to a character index.
pub fn pos_at_coords(text: RopeSlice, coords: Position) -> usize {
+ // TODO: this isn't correct. This needs to work in terms of
+ // visual horizontal position, not graphemes.
let Position { row, col } = coords;
let line_start = text.line_to_char(row);
// line_start + col