aboutsummaryrefslogtreecommitdiff
path: root/helix-core
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-01-08 07:31:19 +0000
committerBlaž Hrastnik2021-01-08 07:37:36 +0000
commit777a80917db01e658139da11a20ff08256667cfe (patch)
treebe813dfd5f59a6f4c4db937c12769927d8d42c13 /helix-core
parent7d41550a23fc3506a37016d5bc362144fb00c080 (diff)
Address clippy lints.
Diffstat (limited to 'helix-core')
-rw-r--r--helix-core/src/indent.rs12
-rw-r--r--helix-core/src/transaction.rs10
2 files changed, 9 insertions, 13 deletions
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<Nod
Some(node)
}
-fn walk(node: Option<Node>, newline: bool) -> usize {
+fn calculate_indentation(node: Option<Node>, 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<Self, ()> {
+ 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");