diff options
author | Pascal Kuthe | 2023-02-09 22:27:08 +0000 |
---|---|---|
committer | GitHub | 2023-02-09 22:27:08 +0000 |
commit | 8a3ec443f176218384db8c8610bbada9c43a6ea5 (patch) | |
tree | 5b8ada854a35d6afd530a33943bfacef338d84f8 /helix-term/src | |
parent | 9d73a0d1128f8237eef2d4bf475496d4db081df2 (diff) |
Fix new clippy lints (#5892)
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/commands.rs | 8 | ||||
-rw-r--r-- | helix-term/src/lib.rs | 2 | ||||
-rw-r--r-- | helix-term/src/ui/document.rs | 12 | ||||
-rw-r--r-- | helix-term/src/ui/editor.rs | 9 | ||||
-rw-r--r-- | helix-term/src/ui/fuzzy_match.rs | 2 |
5 files changed, 15 insertions, 18 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index d7d87b5a..84daaef4 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -959,9 +959,11 @@ fn goto_window(cx: &mut Context, align: Align) { Align::Bottom => { view.offset.vertical_offset + last_visual_line.saturating_sub(scrolloff + count) } - } - .max(view.offset.vertical_offset + scrolloff) - .min(view.offset.vertical_offset + last_visual_line.saturating_sub(scrolloff)); + }; + let visual_line = visual_line.clamp( + view.offset.vertical_offset + scrolloff, + view.offset.vertical_offset + last_visual_line.saturating_sub(scrolloff), + ); let pos = view .pos_at_visual_coords(doc, visual_line as u16, 0, false) diff --git a/helix-term/src/lib.rs b/helix-term/src/lib.rs index f0bc9129..2f6ec12b 100644 --- a/helix-term/src/lib.rs +++ b/helix-term/src/lib.rs @@ -42,7 +42,7 @@ fn filter_picker_entry(entry: &DirEntry, root: &Path, dedup_symlinks: bool) -> b .path() .canonicalize() .ok() - .map_or(false, |path| !path.starts_with(&root)); + .map_or(false, |path| !path.starts_with(root)); } true diff --git a/helix-term/src/ui/document.rs b/helix-term/src/ui/document.rs index ddbb2cf3..ed4b1de9 100644 --- a/helix-term/src/ui/document.rs +++ b/helix-term/src/ui/document.rs @@ -402,7 +402,7 @@ impl<'a> TextRenderer<'a> { is_in_indent_area: &mut bool, position: Position, ) { - let cut_off_start = self.col_offset.saturating_sub(position.col as usize); + let cut_off_start = self.col_offset.saturating_sub(position.col); let is_whitespace = grapheme.is_whitespace(); // TODO is it correct to apply the whitspace style to all unicode white spaces? @@ -413,7 +413,7 @@ impl<'a> TextRenderer<'a> { let width = grapheme.width(); let grapheme = match grapheme { Grapheme::Tab { width } => { - let grapheme_tab_width = char_to_byte_idx(&self.tab, width as usize); + let grapheme_tab_width = char_to_byte_idx(&self.tab, width); &self.tab[..grapheme_tab_width] } // TODO special rendering for other whitespaces? @@ -423,8 +423,8 @@ impl<'a> TextRenderer<'a> { Grapheme::Newline => &self.newline, }; - let in_bounds = self.col_offset <= (position.col as usize) - && (position.col as usize) < self.viewport.width as usize + self.col_offset; + let in_bounds = self.col_offset <= position.col + && position.col < self.viewport.width as usize + self.col_offset; if in_bounds { self.surface.set_string( @@ -433,10 +433,10 @@ impl<'a> TextRenderer<'a> { grapheme, style, ); - } else if cut_off_start != 0 && cut_off_start < width as usize { + } else if cut_off_start != 0 && cut_off_start < width { // partially on screen let rect = Rect::new( - self.viewport.x as u16, + self.viewport.x, self.viewport.y + position.row as u16, (width - cut_off_start) as u16, 1, diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 493f8d50..59f371bd 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -206,7 +206,7 @@ impl EditorView { highlights, theme, &mut line_decorations, - &mut *translated_positions, + &mut translated_positions, ); Self::render_rulers(editor, doc, view, inner, surface, theme); @@ -723,12 +723,7 @@ impl EditorView { let viewport = view.area; let line_decoration = move |renderer: &mut TextRenderer, pos: LinePos| { - let area = Rect::new( - viewport.x, - viewport.y + pos.visual_line as u16, - viewport.width, - 1, - ); + let area = Rect::new(viewport.x, viewport.y + pos.visual_line, viewport.width, 1); if primary_line == pos.doc_line { renderer.surface.set_style(area, primary_style); } else if secondary_lines.binary_search(&pos.doc_line).is_ok() { diff --git a/helix-term/src/ui/fuzzy_match.rs b/helix-term/src/ui/fuzzy_match.rs index e6a3f03a..b406702f 100644 --- a/helix-term/src/ui/fuzzy_match.rs +++ b/helix-term/src/ui/fuzzy_match.rs @@ -25,7 +25,7 @@ impl QueryAtom { _ => QueryAtomKind::Fuzzy, }; - if atom.starts_with(&['^', '\'']) { + if atom.starts_with(['^', '\'']) { atom.remove(0); } |