aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/editor.rs
diff options
context:
space:
mode:
authorNathan Vegdahl2021-07-19 16:25:10 +0000
committerNathan Vegdahl2021-07-19 16:25:10 +0000
commitb0311f4fc246f370bb317ab0b1fcb89823347caa (patch)
tree7bb7f6783cdba83d784af2bcbd780e57a32c715c /helix-view/src/editor.rs
parent079d4ed86df30c78ca00fd4b86f906c3ea9df7db (diff)
Fixed primary cursor position calculation to use 1-width semantics.
This had a bunch of knock-on effects that were buggy, such as bracket match highlighting.
Diffstat (limited to 'helix-view/src/editor.rs')
-rw-r--r--helix-view/src/editor.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index cd9d0a92..1cd0af02 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -141,12 +141,11 @@ impl Editor {
let (view, doc) = current!(self);
// initialize selection for view
- let selection = doc
- .selections
+ doc.selections
.entry(view.id)
.or_insert_with(|| Selection::point(0));
// TODO: reuse align_view
- let pos = selection.cursor();
+ let pos = doc.selection(view.id).cursor(doc.text().slice(..));
let line = doc.text().char_to_line(pos);
view.first_line = line.saturating_sub(view.area.height as usize / 2);
@@ -296,7 +295,7 @@ impl Editor {
const OFFSET: u16 = 7; // 1 diagnostic + 5 linenr + 1 gutter
let view = view!(self);
let doc = &self.documents[view.doc];
- let cursor = doc.selection(view.id).cursor();
+ let cursor = doc.selection(view.id).cursor(doc.text().slice(..));
if let Some(mut pos) = view.screen_coords_at_pos(doc, doc.text().slice(..), cursor) {
pos.col += view.area.x as usize + OFFSET as usize;
pos.row += view.area.y as usize;