Skip to content

Commit 3a2be7e

Browse files
matoousShekhinah Memmel
authored andcommitted
feat(view): re-use align_view function (helix-editor#4390)
1 parent 7932980 commit 3a2be7e

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

helix-view/src/editor.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
use crate::{
2+
align_view,
23
clipboard::{get_clipboard_provider, ClipboardProvider},
34
document::{DocumentSavedEventFuture, DocumentSavedEventResult, Mode},
45
graphics::{CursorKind, Rect},
56
info::Info,
67
input::KeyEvent,
78
theme::{self, Theme},
89
tree::{self, Tree},
9-
Document, DocumentId, View, ViewId,
10+
Align, Document, DocumentId, View, ViewId,
1011
};
1112

1213
use futures_util::stream::select_all::SelectAll;
@@ -1023,13 +1024,7 @@ impl Editor {
10231024
let doc = doc_mut!(self, &doc_id);
10241025
doc.ensure_view_init(view.id);
10251026

1026-
// TODO: reuse align_view
1027-
let pos = doc
1028-
.selection(view.id)
1029-
.primary()
1030-
.cursor(doc.text().slice(..));
1031-
let line = doc.text().char_to_line(pos);
1032-
view.offset.row = line.saturating_sub(view.inner_area().height as usize / 2);
1027+
align_view(doc, view, Align::Center);
10331028
}
10341029

10351030
pub fn switch(&mut self, id: DocumentId, action: Action) {

0 commit comments

Comments
 (0)