diff options
author | Ivan Tham | 2021-11-03 03:02:29 +0000 |
---|---|---|
committer | GitHub | 2021-11-03 03:02:29 +0000 |
commit | 3eb829e2330fed5ad1c095f8bba44f62361b4943 (patch) | |
tree | 400ee47dd753eb318774f9ab02934f0e70b92597 /helix-view | |
parent | ee889aaa854d0036da3bae16252bc382e50b0df6 (diff) |
Ensure coords in screen depends on char width (#885)
The issue affected files with lots of tabs at the start as well.
Fix #840
Diffstat (limited to 'helix-view')
-rw-r--r-- | helix-view/src/view.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs index 01f18c71..11f30155 100644 --- a/helix-view/src/view.rs +++ b/helix-view/src/view.rs @@ -2,10 +2,9 @@ use std::borrow::Cow; use crate::{graphics::Rect, Document, DocumentId, ViewId}; use helix_core::{ - coords_at_pos, graphemes::{grapheme_width, RopeGraphemes}, line_ending::line_end_char_index, - Position, RopeSlice, Selection, + visual_coords_at_pos, Position, RopeSlice, Selection, }; type Jump = (DocumentId, Selection); @@ -91,7 +90,10 @@ impl View { .selection(self.id) .primary() .cursor(doc.text().slice(..)); - let Position { col, row: line } = coords_at_pos(doc.text().slice(..), cursor); + + let Position { col, row: line } = + visual_coords_at_pos(doc.text().slice(..), cursor, doc.tab_width()); + let inner_area = self.inner_area(); let last_line = (self.offset.row + inner_area.height as usize).saturating_sub(1); |