Document::new should just take a rope.

pull/11/head
Blaž Hrastnik 4 years ago
parent e261f3c50d
commit 2b64f49f2c

@ -63,13 +63,13 @@ use helix_lsp::lsp;
use url::Url; use url::Url;
impl Document { impl Document {
pub fn new(state: State) -> Self { pub fn new(text: Rope) -> Self {
let changes = ChangeSet::new(&state.doc); let changes = ChangeSet::new(&text);
let old_state = None; let old_state = None;
Self { Self {
path: None, path: None,
state, state: State::new(text),
mode: Mode::Normal, mode: Mode::Normal,
restore_cursor: false, restore_cursor: false,
syntax: None, syntax: None,
@ -93,7 +93,7 @@ impl Document {
// TODO: create if not found // TODO: create if not found
let mut doc = Self::new(State::new(doc)); let mut doc = Self::new(doc);
let language_config = LOADER.language_config_for_file_name(path.as_path()); let language_config = LOADER.language_config_for_file_name(path.as_path());
doc.set_language(language_config, scopes); doc.set_language(language_config, scopes);
@ -340,13 +340,10 @@ mod test {
#[test] #[test]
fn changeset_to_changes() { fn changeset_to_changes() {
use helix_core::{Rope, State, Transaction};
// use helix_view::Document;
use helix_lsp::{lsp, Client}; use helix_lsp::{lsp, Client};
let text = Rope::from("hello"); let text = Rope::from("hello");
let mut state = State::new(text); let mut doc = Document::new(text);
state.selection = Selection::single(5, 5); doc.set_selection(Selection::single(5, 5));
let mut doc = Document::new(state);
// insert // insert

Loading…
Cancel
Save