diff options
author | Blaž Hrastnik | 2020-09-07 02:28:52 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2020-09-07 02:28:52 +0000 |
commit | 8b3e152126ec8f0e67dad378dc62c734ea97a4b0 (patch) | |
tree | 5109f5fb4a7709eafd2fb3b493c6e7d56e269e5a /helix-term | |
parent | 579b6899f1fe7f0a06857c4528f55f316e2975e9 (diff) |
cleanup: Make Buffer just a part of State.
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/src/editor.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/helix-term/src/editor.rs b/helix-term/src/editor.rs index ef4af3dc..4abc8477 100644 --- a/helix-term/src/editor.rs +++ b/helix-term/src/editor.rs @@ -9,7 +9,7 @@ use crossterm::{ terminal::{self, disable_raw_mode, enable_raw_mode}, }; use futures::{future::FutureExt, select, StreamExt}; -use helix_core::{state::coords_at_pos, state::Mode, Buffer, State}; +use helix_core::{state::coords_at_pos, state::Mode, State}; use std::io::{self, stdout, Write}; use std::path::PathBuf; use std::time::Duration; @@ -38,9 +38,7 @@ impl Editor { } pub fn open(&mut self, path: PathBuf) -> Result<(), Error> { - let buffer = Buffer::load(path)?; - let state = State::new(buffer); - self.state = Some(state); + self.state = Some(State::load(path)?); Ok(()) } @@ -48,7 +46,7 @@ impl Editor { match &self.state { Some(state) => { let lines = state - .contents() + .doc .lines_at(self.first_line as usize) .take(self.size.1 as usize) .map(|x| x.as_str().unwrap()); @@ -90,7 +88,7 @@ impl Editor { // render the cursor let pos = state.selection.primary().head; - let coords = coords_at_pos(&state.doc.contents.slice(..), pos); + let coords = coords_at_pos(&state.doc.slice(..), pos); execute!( stdout, cursor::MoveTo((coords.1 + 2) as u16, coords.0 as u16) |