aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-03-18 05:44:32 +0000
committerBlaž Hrastnik2021-03-18 05:44:32 +0000
commit2b64f49f2c5da800ceae43359c91b9708e953d18 (patch)
tree3855cf9d9cbf154856f24ff1e6fc4dd42abcece1 /helix-view/src
parente261f3c50d0e06860ffbeee0178381fa789dfd96 (diff)
Document::new should just take a rope.
Diffstat (limited to 'helix-view/src')
-rw-r--r--helix-view/src/document.rs15
1 files changed, 6 insertions, 9 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 36bca5fe..6ccbfbec 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -63,13 +63,13 @@ use helix_lsp::lsp;
use url::Url;
impl Document {
- pub fn new(state: State) -> Self {
- let changes = ChangeSet::new(&state.doc);
+ pub fn new(text: Rope) -> Self {
+ let changes = ChangeSet::new(&text);
let old_state = None;
Self {
path: None,
- state,
+ state: State::new(text),
mode: Mode::Normal,
restore_cursor: false,
syntax: None,
@@ -93,7 +93,7 @@ impl Document {
// 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());
doc.set_language(language_config, scopes);
@@ -340,13 +340,10 @@ mod test {
#[test]
fn changeset_to_changes() {
- use helix_core::{Rope, State, Transaction};
- // use helix_view::Document;
use helix_lsp::{lsp, Client};
let text = Rope::from("hello");
- let mut state = State::new(text);
- state.selection = Selection::single(5, 5);
- let mut doc = Document::new(state);
+ let mut doc = Document::new(text);
+ doc.set_selection(Selection::single(5, 5));
// insert