aboutsummaryrefslogtreecommitdiff
path: root/helix-view
diff options
context:
space:
mode:
Diffstat (limited to 'helix-view')
-rw-r--r--helix-view/src/base64.rs2
-rw-r--r--helix-view/src/clipboard.rs2
-rw-r--r--helix-view/src/document.rs2
-rw-r--r--helix-view/src/gutter.rs8
-rw-r--r--helix-view/src/input.rs2
-rw-r--r--helix-view/src/view.rs2
6 files changed, 8 insertions, 10 deletions
diff --git a/helix-view/src/base64.rs b/helix-view/src/base64.rs
index a0dc167f..13ee919d 100644
--- a/helix-view/src/base64.rs
+++ b/helix-view/src/base64.rs
@@ -36,7 +36,7 @@ const LOW_SIX_BITS: u32 = 0x3F;
pub fn encode(input: &[u8]) -> String {
let rem = input.len() % 3;
let complete_chunks = input.len() / 3;
- let remainder_chunk = if rem == 0 { 0 } else { 1 };
+ let remainder_chunk = usize::from(rem != 0);
let encoded_size = (complete_chunks + remainder_chunk) * 4;
let mut output = vec![0; encoded_size];
diff --git a/helix-view/src/clipboard.rs b/helix-view/src/clipboard.rs
index 96c87d3f..d43d632a 100644
--- a/helix-view/src/clipboard.rs
+++ b/helix-view/src/clipboard.rs
@@ -258,7 +258,7 @@ pub mod provider {
.args(args)
.output()
.ok()
- .and_then(|out| out.status.success().then(|| ())) // TODO: use then_some when stabilized
+ .and_then(|out| out.status.success().then_some(()))
.is_some()
}
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index d308d013..11a0dbf8 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -1096,7 +1096,7 @@ impl Document {
/// Language server if it has been initialized.
pub fn language_server(&self) -> Option<&helix_lsp::Client> {
let server = self.language_server.as_deref()?;
- server.is_initialized().then(|| server)
+ server.is_initialized().then_some(server)
}
pub fn diff_handle(&self) -> Option<&DiffHandle> {
diff --git a/helix-view/src/gutter.rs b/helix-view/src/gutter.rs
index 90c94d55..cb9e4333 100644
--- a/helix-view/src/gutter.rs
+++ b/helix-view/src/gutter.rs
@@ -7,9 +7,8 @@ use crate::{
};
fn count_digits(n: usize) -> usize {
- // NOTE: if int_log gets standardized in stdlib, can use checked_log10
- // (https://github.com/rust-lang/rust/issues/70887#issue)
- std::iter::successors(Some(n), |&n| (n >= 10).then(|| n / 10)).count()
+ // TODO: use checked_log10 when MSRV reaches 1.67
+ std::iter::successors(Some(n), |&n| (n >= 10).then_some(n / 10)).count()
}
pub type GutterFn<'doc> = Box<dyn FnMut(usize, bool, bool, &mut String) -> Option<Style> + 'doc>;
@@ -199,8 +198,7 @@ pub fn line_numbers<'doc>(
write!(out, "{:>1$}", " ", width).unwrap();
}
- // TODO: Use then_some when MSRV reaches 1.62
- first_visual_line.then(|| style)
+ first_visual_line.then_some(style)
}
},
)
diff --git a/helix-view/src/input.rs b/helix-view/src/input.rs
index bda0520e..d8832adc 100644
--- a/helix-view/src/input.rs
+++ b/helix-view/src/input.rs
@@ -380,7 +380,7 @@ impl std::str::FromStr for KeyEvent {
let function: String = function.chars().skip(1).collect();
let function = str::parse::<u8>(&function)?;
(function > 0 && function < 13)
- .then(|| KeyCode::F(function))
+ .then_some(KeyCode::F(function))
.ok_or_else(|| anyhow!("Invalid function key '{}'", function))?
}
invalid => return Err(anyhow!("Invalid key code '{}'", invalid)),
diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs
index 660cce65..f793cbe3 100644
--- a/helix-view/src/view.rs
+++ b/helix-view/src/view.rs
@@ -243,7 +243,7 @@ impl View {
true
}
Some((visual_pos, _)) if visual_pos.row >= vertical_viewport_end - scrolloff => {
- if CENTERING && visual_pos.row >= vertical_viewport_end as usize {
+ if CENTERING && visual_pos.row >= vertical_viewport_end {
// cursor out of view
return None;
}