feat(view): re-use align_view function (#4390)

pull/4397/head
Matouš Dzivjak 2 years ago committed by GitHub
parent 66238e8556
commit e25af1f744
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +1,5 @@
use crate::{ use crate::{
align_view,
clipboard::{get_clipboard_provider, ClipboardProvider}, clipboard::{get_clipboard_provider, ClipboardProvider},
document::{DocumentSavedEventFuture, DocumentSavedEventResult, Mode}, document::{DocumentSavedEventFuture, DocumentSavedEventResult, Mode},
graphics::{CursorKind, Rect}, graphics::{CursorKind, Rect},
@ -6,7 +7,7 @@ use crate::{
input::KeyEvent, input::KeyEvent,
theme::{self, Theme}, theme::{self, Theme},
tree::{self, Tree}, tree::{self, Tree},
Document, DocumentId, View, ViewId, Align, Document, DocumentId, View, ViewId,
}; };
use futures_util::stream::select_all::SelectAll; use futures_util::stream::select_all::SelectAll;
@ -957,13 +958,7 @@ impl Editor {
let doc = doc_mut!(self, &doc_id); let doc = doc_mut!(self, &doc_id);
doc.ensure_view_init(view.id); doc.ensure_view_init(view.id);
// TODO: reuse align_view align_view(doc, view, Align::Center);
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);
} }
pub fn switch(&mut self, id: DocumentId, action: Action) { pub fn switch(&mut self, id: DocumentId, action: Action) {

Loading…
Cancel
Save