diff options
author | Matouš Dzivjak | 2022-10-20 23:53:05 +0000 |
---|---|---|
committer | GitHub | 2022-10-20 23:53:05 +0000 |
commit | e25af1f7441fd1eccae580ba2e8e0eebc2be74f8 (patch) | |
tree | 312f6739b0b46c56e9e424a3240ee5a10043f957 | |
parent | 66238e855666f979306dc8698aeb0f35aaa84776 (diff) |
feat(view): re-use align_view function (#4390)
-rw-r--r-- | helix-view/src/editor.rs | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index cd2b1ad4..fe243b92 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -1,4 +1,5 @@ use crate::{ + align_view, clipboard::{get_clipboard_provider, ClipboardProvider}, document::{DocumentSavedEventFuture, DocumentSavedEventResult, Mode}, graphics::{CursorKind, Rect}, @@ -6,7 +7,7 @@ use crate::{ input::KeyEvent, theme::{self, Theme}, tree::{self, Tree}, - Document, DocumentId, View, ViewId, + Align, Document, DocumentId, View, ViewId, }; use futures_util::stream::select_all::SelectAll; @@ -957,13 +958,7 @@ impl Editor { let doc = doc_mut!(self, &doc_id); doc.ensure_view_init(view.id); - // TODO: reuse align_view - let pos = doc - .selection(view.id) - .primary() - .cursor(doc.text().slice(..)); - let line = doc.text().char_to_line(pos); - view.offset.row = line.saturating_sub(view.inner_area().height as usize / 2); + align_view(doc, view, Align::Center); } pub fn switch(&mut self, id: DocumentId, action: Action) { |