aboutsummaryrefslogtreecommitdiff
path: root/helix-core
diff options
context:
space:
mode:
authorPascal Kuthe2023-02-09 22:27:08 +0000
committerGitHub2023-02-09 22:27:08 +0000
commit8a3ec443f176218384db8c8610bbada9c43a6ea5 (patch)
tree5b8ada854a35d6afd530a33943bfacef338d84f8 /helix-core
parent9d73a0d1128f8237eef2d4bf475496d4db081df2 (diff)
Fix new clippy lints (#5892)
Diffstat (limited to 'helix-core')
-rw-r--r--helix-core/src/comment.rs2
-rw-r--r--helix-core/src/increment/integer.rs4
-rw-r--r--helix-core/src/indent.rs4
-rw-r--r--helix-core/src/syntax.rs2
4 files changed, 6 insertions, 6 deletions
diff --git a/helix-core/src/comment.rs b/helix-core/src/comment.rs
index ec5d7a45..6241f7fd 100644
--- a/helix-core/src/comment.rs
+++ b/helix-core/src/comment.rs
@@ -68,7 +68,7 @@ pub fn toggle_line_comments(doc: &Rope, selection: &Selection, token: Option<&st
let mut min_next_line = 0;
for selection in selection {
let (start, end) = selection.line_range(text);
- let start = start.max(min_next_line).min(text.len_lines());
+ let start = start.clamp(min_next_line, text.len_lines());
let end = (end + 1).min(text.len_lines());
lines.extend(start..end);
diff --git a/helix-core/src/increment/integer.rs b/helix-core/src/increment/integer.rs
index 30803e17..0dfabc0d 100644
--- a/helix-core/src/increment/integer.rs
+++ b/helix-core/src/increment/integer.rs
@@ -69,8 +69,8 @@ pub fn increment(selected_text: &str, amount: i64) -> Option<String> {
let (lower_count, upper_count): (usize, usize) =
number.chars().fold((0, 0), |(lower, upper), c| {
(
- lower + c.is_ascii_lowercase().then(|| 1).unwrap_or(0),
- upper + c.is_ascii_uppercase().then(|| 1).unwrap_or(0),
+ lower + c.is_ascii_lowercase() as usize,
+ upper + c.is_ascii_uppercase() as usize,
)
});
if upper_count > lower_count {
diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs
index d6aa5edb..3aa59fa3 100644
--- a/helix-core/src/indent.rs
+++ b/helix-core/src/indent.rs
@@ -604,7 +604,7 @@ pub fn treesitter_indent_for_pos(
&mut cursor,
text,
query_range,
- new_line.then(|| (line, byte_pos)),
+ new_line.then_some((line, byte_pos)),
);
ts_parser.cursors.push(cursor);
(query_result, deepest_preceding)
@@ -624,7 +624,7 @@ pub fn treesitter_indent_for_pos(
tab_width,
);
}
- let mut first_in_line = get_first_in_line(node, new_line.then(|| byte_pos));
+ let mut first_in_line = get_first_in_line(node, new_line.then_some(byte_pos));
let mut result = Indentation::default();
// We always keep track of all the indent changes on one line, in order to only indent once
diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs
index ca4da3dc..1b6c1b1d 100644
--- a/helix-core/src/syntax.rs
+++ b/helix-core/src/syntax.rs
@@ -427,7 +427,7 @@ impl TextObjectQuery {
let nodes: Vec<_> = mat
.captures
.iter()
- .filter_map(|cap| (cap.index == capture_idx).then(|| cap.node))
+ .filter_map(|cap| (cap.index == capture_idx).then_some(cap.node))
.collect();
if nodes.len() > 1 {