diff options
author | Philipp Mildenberger | 2023-03-27 23:33:55 +0000 |
---|---|---|
committer | GitHub | 2023-03-27 23:33:55 +0000 |
commit | 198ff2c3f9c56afe4649cc0ecbb09ded5fd4a7c7 (patch) | |
tree | 5e896645a77ce94046ae39dbe868e6574d663a93 | |
parent | 5323020c3f02b178f2b6807f13d89bf7f40d3cce (diff) |
Fix clippy lints (#6454)
-rw-r--r-- | helix-core/src/position.rs | 4 | ||||
-rw-r--r-- | helix-term/src/commands.rs | 4 | ||||
-rw-r--r-- | helix-tui/src/widgets/block.rs | 9 | ||||
-rw-r--r-- | helix-view/src/editor.rs | 9 |
4 files changed, 8 insertions, 18 deletions
diff --git a/helix-core/src/position.rs b/helix-core/src/position.rs index 3902b4d4..04bf8c31 100644 --- a/helix-core/src/position.rs +++ b/helix-core/src/position.rs @@ -309,8 +309,8 @@ pub fn pos_at_visual_coords(text: RopeSlice, coords: Position, tab_width: usize) /// on the visual line is returned if the visual line contains any text: /// If the visual line at the specified offset is a virtual line generated by a `LineAnnotation` /// the previous char_index is returned, together with the remaining vertical offset (`virtual_lines`) -pub fn char_idx_at_visual_offset<'a>( - text: RopeSlice<'a>, +pub fn char_idx_at_visual_offset( + text: RopeSlice, mut anchor: usize, mut row_offset: isize, column: usize, diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 4a7b7883..2f41a2dc 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -501,7 +501,7 @@ impl std::str::FromStr for MappableCommand { fn from_str(s: &str) -> Result<Self, Self::Err> { if let Some(suffix) = s.strip_prefix(':') { - let mut typable_command = suffix.split(' ').into_iter().map(|arg| arg.trim()); + let mut typable_command = suffix.split(' ').map(|arg| arg.trim()); let name = typable_command .next() .ok_or_else(|| anyhow!("Expected typable command name"))?; @@ -1470,7 +1470,7 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) { let cursor = range.cursor(text); let height = view.inner_height(); - let scrolloff = config.scrolloff.min(height.saturating_sub(1) as usize / 2); + let scrolloff = config.scrolloff.min(height.saturating_sub(1) / 2); let offset = match direction { Forward => offset as isize, Backward => -(offset as isize), diff --git a/helix-tui/src/widgets/block.rs b/helix-tui/src/widgets/block.rs index 98f84abe..a6fdde4c 100644 --- a/helix-tui/src/widgets/block.rs +++ b/helix-tui/src/widgets/block.rs @@ -7,8 +7,9 @@ use crate::{ use helix_view::graphics::{Rect, Style}; /// Border render type. Defaults to [`BorderType::Plain`]. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] pub enum BorderType { + #[default] Plain, Rounded, Double, @@ -26,12 +27,6 @@ impl BorderType { } } -impl Default for BorderType { - fn default() -> BorderType { - BorderType::Plain - } -} - /// Base widget to be used with all upper level ones. It may be used to display a box border around /// the widget and/or add a title. /// diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 7207baf3..ee535b5c 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -532,10 +532,11 @@ impl Default for CursorShapeConfig { } /// bufferline render modes -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "kebab-case")] pub enum BufferLine { /// Don't render bufferline + #[default] Never, /// Always render Always, @@ -543,12 +544,6 @@ pub enum BufferLine { Multiple, } -impl Default for BufferLine { - fn default() -> Self { - BufferLine::Never - } -} - #[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "kebab-case")] pub enum LineNumber { |