diff options
Diffstat (limited to 'helix-view')
-rw-r--r-- | helix-view/src/editor.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 43311484..cf4dce28 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -81,11 +81,15 @@ impl Editor { view.jumps.push(jump); view.doc = id; view.first_line = 0; - let view_id = view.id; + + let (view, doc) = self.current(); // initialize selection for view - let doc = &mut self.documents[id]; - doc.selections.insert(view_id, Selection::point(0)); + let selection = doc.selections.entry(view.id).or_insert(Selection::point(0)); + // TODO: reuse align_view + let pos = selection.cursor(); + let line = doc.text().char_to_line(pos); + view.first_line = line.saturating_sub(view.area.height as usize / 2); return; } |