diff options
author | Blaž Hrastnik | 2020-10-23 02:36:46 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2020-12-03 04:10:35 +0000 |
commit | efc5aa2016e56e0721d125a20e3573d25af4dd76 (patch) | |
tree | 7db8aa4c14c5d2873fb0acd4bba54a36eef9f410 /helix-view/src | |
parent | c0e17dd324f016401d56d66b7c113dada0644155 (diff) |
Simplify old_state handling.
Diffstat (limited to 'helix-view/src')
-rw-r--r-- | helix-view/src/commands.rs | 8 | ||||
-rw-r--r-- | helix-view/src/document.rs | 4 |
2 files changed, 3 insertions, 9 deletions
diff --git a/helix-view/src/commands.rs b/helix-view/src/commands.rs index 6bf89040..06c4b9e0 100644 --- a/helix-view/src/commands.rs +++ b/helix-view/src/commands.rs @@ -411,15 +411,9 @@ fn append_changes_to_history(view: &mut View) { // TODO: trigger lsp/documentDidChange with changes // HAXX: we need to reconstruct the state as it was before the changes.. - let (doc, selection) = view.doc.old_state.take().unwrap(); - let mut old_state = State::new(doc); - old_state.selection = selection; - + let old_state = std::mem::replace(&mut view.doc.old_state, view.doc.state.clone()); // TODO: take transaction by value? view.doc.history.commit_revision(&transaction, &old_state); - - // HAXX - view.doc.old_state = Some((view.doc.text().clone(), view.doc.state.selection.clone())); } pub fn normal_mode(view: &mut View, _count: usize) { diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 04018ed6..22438926 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -27,9 +27,9 @@ pub struct Document { /// Pending changes since last history commit. pub changes: ChangeSet, + pub old_state: State, pub history: History, pub version: i64, // should be usize? - pub old_state: Option<(Rope, Selection)>, pub diagnostics: Vec<Diagnostic>, } @@ -55,7 +55,7 @@ use url::Url; impl Document { fn new(state: State) -> Self { let changes = ChangeSet::new(&state.doc); - let old_state = Some((state.doc.clone(), Selection::single(0, 0))); + let old_state = state.clone(); Self { path: None, |