Skip to content

Commit

Permalink
feat(view): re-use align_view function (helix-editor#4390)
Browse files Browse the repository at this point in the history
  • Loading branch information
matoous authored and Shekhinah Memmel committed Dec 11, 2022
1 parent 7932980 commit 3a2be7e
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use crate::{
align_view,
clipboard::{get_clipboard_provider, ClipboardProvider},
document::{DocumentSavedEventFuture, DocumentSavedEventResult, Mode},
graphics::{CursorKind, Rect},
info::Info,
input::KeyEvent,
theme::{self, Theme},
tree::{self, Tree},
Document, DocumentId, View, ViewId,
Align, Document, DocumentId, View, ViewId,
};

use futures_util::stream::select_all::SelectAll;
Expand Down Expand Up @@ -1023,13 +1024,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) {
Expand Down

0 comments on commit 3a2be7e

Please sign in to comment.