aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/editor.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-07-29 09:43:20 +0000
committerGitHub2021-07-29 09:43:20 +0000
commit05d20e196f81c8b71c2aecaf46f5d443d6b6b582 (patch)
tree0642d43c12f16ac3c68c19602c64fdea8108cc97 /helix-view/src/editor.rs
parent8a2fa692f26f5bff5861151f395304837f5d93ec (diff)
parente4d41d06e3b52863d35ce3703f78cc8e0807c504 (diff)
Merge pull request #376 from cessen/great_line_ending_and_cursor_range_cleanup
The Great Line Ending & Cursor Range Cleanup
Diffstat (limited to 'helix-view/src/editor.rs')
-rw-r--r--helix-view/src/editor.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index 7ff689df..7e8548e7 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -138,12 +138,14 @@ 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)
+ .primary()
+ .cursor(doc.text().slice(..));
let line = doc.text().char_to_line(pos);
view.first_line = line.saturating_sub(view.area.height as usize / 2);
@@ -293,7 +295,10 @@ 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)
+ .primary()
+ .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;