From 777a80917db01e658139da11a20ff08256667cfe Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Fri, 8 Jan 2021 16:31:19 +0900 Subject: Address clippy lints. --- helix-core/src/indent.rs | 12 ++++-------- helix-core/src/transaction.rs | 10 +++++----- 2 files changed, 9 insertions(+), 13 deletions(-) (limited to 'helix-core') diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs index 7fbe7f82..5a416147 100644 --- a/helix-core/src/indent.rs +++ b/helix-core/src/indent.rs @@ -44,7 +44,7 @@ fn get_highest_syntax_node_at_bytepos(syntax: &Syntax, pos: usize) -> Option, newline: bool) -> usize { +fn calculate_indentation(node: Option, newline: bool) -> usize { let mut increment = 0; // Hardcoded for rust for now @@ -183,13 +183,9 @@ pub fn suggested_indent_for_pos( let byte_start = state.doc.char_to_byte(pos); let node = get_highest_syntax_node_at_bytepos(syntax, byte_start); - let indentation = walk(node, new_line); - // special case for comments - - // println!("------------"); - // if preserve_leading_whitespace - - indentation + // TODO: special case for comments + // TODO: if preserve_leading_whitespace + calculate_indentation(node, new_line) } else { // TODO: heuristics for non-tree sitter grammars 0 diff --git a/helix-core/src/transaction.rs b/helix-core/src/transaction.rs index f1cb2ca1..eec947df 100644 --- a/helix-core/src/transaction.rs +++ b/helix-core/src/transaction.rs @@ -66,7 +66,7 @@ impl ChangeSet { /// Combine two changesets together. /// In other words, If `this` goes `docA` → `docB` and `other` represents `docB` → `docC`, the /// returned value will represent the change `docA` → `docC`. - pub fn compose(self, other: ChangeSet) -> Result { + pub fn compose(self, other: ChangeSet) -> Self { debug_assert!(self.len_after() == other.len); let len = self.changes.len(); @@ -99,7 +99,7 @@ impl ChangeSet { head_a = a; head_b = changes_b.next(); } - (None, _) | (_, None) => return Err(()), + (None, _) | (_, None) => return unreachable!(), (Some(Retain(i)), Some(Retain(j))) => match i.cmp(&j) { Ordering::Less => { changes.push(Retain(i)); @@ -180,10 +180,10 @@ impl ChangeSet { }; } - Ok(Self { + Self { len: self.len, changes, - }) + } } /// Given another change set starting in the same document, maps this @@ -496,7 +496,7 @@ mod test { let mut text = Rope::from("hello xz"); // should probably return cloned text - let composed = a.compose(b).unwrap(); + let composed = a.compose(b); assert_eq!(composed.len, 8); assert!(composed.apply(&mut text)); assert_eq!(text, "world! abc"); -- cgit v1.2.3-70-g09d2