From 93ac2604b2ae300ab483537ef23034d48d768c8e Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 27 Sep 2019 14:55:15 -0400 Subject: [PATCH] Simplify editor constructor --- src/editor.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/editor.rs b/src/editor.rs index 9f24736..9f9bdde 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -237,14 +237,13 @@ impl Editor { // ------------------------------------------------------------------------ pub fn new() -> Self { - let mut instance = Self::default(); + let size = Self::get_window_size(); - let size = instance.get_window_size(); - - instance.screen_cols = size.cols as usize; - instance.screen_rows = (size.rows - 2) as usize; - - instance + Editor { + screen_cols: size.cols as usize, + screen_rows: (size.rows - 2) as usize, + ..Editor::default() + } } // ------------------------------------------------------------------------ @@ -420,7 +419,7 @@ impl Editor { } /// Get terminal size in rows and columns - fn get_window_size(&mut self) -> TermSize { + fn get_window_size() -> TermSize { match get_term_size() { Some(size) => size, None => get_cursor_position(),