diff options
author | Nathan Vegdahl | 2021-07-02 02:37:28 +0000 |
---|---|---|
committer | Nathan Vegdahl | 2021-07-02 02:37:28 +0000 |
commit | 2224a1527ec9592f16131b0aa3923fc3d37592e7 (patch) | |
tree | 2a08b053cb32cef9dc1db5895778d419ebaebb5b /helix-core/src/transaction.rs | |
parent | e725957704274b1ec814a34ddf6f75faf35358e7 (diff) | |
parent | 9f62ad0715240156b512dfc7c584d2d0df05a664 (diff) |
Merge branch 'master' into great_line_ending_and_cursor_range_cleanup
Diffstat (limited to 'helix-core/src/transaction.rs')
-rw-r--r-- | helix-core/src/transaction.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/helix-core/src/transaction.rs b/helix-core/src/transaction.rs index 10219142..048839b3 100644 --- a/helix-core/src/transaction.rs +++ b/helix-core/src/transaction.rs @@ -1,5 +1,5 @@ -use crate::{Range, Rope, Selection, State, Tendril}; -use std::{borrow::Cow, convert::TryFrom}; +use crate::{Range, Rope, Selection, Tendril}; +use std::borrow::Cow; /// (from, to, replacement) pub type Change = (usize, usize, Option<Tendril>); @@ -163,7 +163,7 @@ impl ChangeSet { head_a = a; head_b = changes_b.next(); } - (None, val) | (val, None) => return unreachable!("({:?})", val), + (None, val) | (val, None) => unreachable!("({:?})", val), (Some(Retain(i)), Some(Retain(j))) => match i.cmp(&j) { Ordering::Less => { changes.retain(i); @@ -202,7 +202,7 @@ impl ChangeSet { } } } - (Some(Insert(mut s)), Some(Retain(j))) => { + (Some(Insert(s)), Some(Retain(j))) => { let len = s.chars().count(); match len.cmp(&j) { Ordering::Less => { @@ -274,7 +274,6 @@ impl ChangeSet { let mut changes = Self::with_capacity(self.changes.len()); let mut pos = 0; - let mut len = 0; for change in &self.changes { use Operation::*; @@ -581,6 +580,7 @@ impl<'a> Iterator for ChangeIterator<'a> { #[cfg(test)] mod test { use super::*; + use crate::State; #[test] fn composition() { @@ -699,7 +699,7 @@ mod test { #[test] fn changes_iter() { - let mut state = State::new("hello world!\ntest 123".into()); + let state = State::new("hello world!\ntest 123".into()); let changes = vec![(6, 11, Some("void".into())), (12, 17, None)]; let transaction = Transaction::change(&state.doc, changes.clone().into_iter()); assert_eq!(transaction.changes_iter().collect::<Vec<_>>(), changes); @@ -731,7 +731,7 @@ mod test { // retain 1, e // retain 2, l - let mut changes = t1 + let changes = t1 .changes .compose(t2.changes) .compose(t3.changes) @@ -746,7 +746,7 @@ mod test { #[test] fn combine_with_empty() { let empty = Rope::from(""); - let mut a = ChangeSet::new(&empty); + let a = ChangeSet::new(&empty); let mut b = ChangeSet::new(&empty); b.insert("a".into()); @@ -762,7 +762,7 @@ mod test { const TEST_CASE: &'static str = "Hello, これはヘリックスエディターです!"; let empty = Rope::from(""); - let mut a = ChangeSet::new(&empty); + let a = ChangeSet::new(&empty); let mut b = ChangeSet::new(&empty); b.insert(TEST_CASE.into()); |