Skip to content

Vi editor improvements #459

Vi editor improvements

Vi editor improvements #459

GitHub Actions / clippy succeeded Nov 7, 2023 in 0s

clippy

24 warnings

Details

Results

Message level Amount
Internal compiler error 0
Error 0
Warning 24
Note 0
Help 0

Versions

  • rustc 1.73.0 (cc66ad468 2023-10-03)
  • cargo 1.73.0 (9c4383fb5 2023-08-26)
  • clippy 0.1.73 (cc66ad4 2023-10-03)

Annotations

Check warning on line 133 in src/edit/mod.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

item in documentation is missing backticks

warning: item in documentation is missing backticks
   --> src/edit/mod.rs:133:38
    |
133 |     /// Set the current tab width. A tab_width of 0 is not allowed, and will be ignored
    |                                      ^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
note: the lint level is defined here
   --> src/lib.rs:84:9
    |
84  | #![warn(clippy::doc_markdown)]
    |         ^^^^^^^^^^^^^^^^^^^^
help: try
    |
133 |     /// Set the current tab width. A `tab_width` of 0 is not allowed, and will be ignored
    |                                      ~~~~~~~~~~~

Check warning on line 600 in src/edit/vi.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

docs for function returning `Result` missing `# Errors` section

warning: docs for function returning `Result` missing `# Errors` section
   --> src/edit/vi.rs:596:5
    |
596 | /     pub fn load_text<P: AsRef<std::path::Path>>(
597 | |         &mut self,
598 | |         path: P,
599 | |         attrs: crate::Attrs,
600 | |     ) -> std::io::Result<()> {
    | |____________________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc

Check warning on line 43 in src/edit/vi.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

docs for function returning `Result` missing `# Errors` section

warning: docs for function returning `Result` missing `# Errors` section
  --> src/edit/vi.rs:38:5
   |
38 | /     pub fn load_text<P: AsRef<std::path::Path>>(
39 | |         &mut self,
40 | |         font_system: &mut FontSystem,
41 | |         path: P,
42 | |         attrs: crate::Attrs,
43 | |     ) -> std::io::Result<()> {
   | |____________________________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc
note: the lint level is defined here
  --> src/lib.rs:86:9
   |
86 | #![warn(clippy::missing_errors_doc)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^

Check warning on line 747 in src/edit/editor.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`

warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
   --> src/edit/editor.rs:738:21
    |
738 | /                     match self.select_opt {
739 | |                         Some(ref mut select) => {
740 | |                             if select.line == line_i {
741 | |                                 if select.index > last_indent {
...   |
746 | |                         None => {}
747 | |                     }
    | |_____________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
help: try
    |
738 ~                     if let Some(ref mut select) = self.select_opt {
739 +                         if select.line == line_i {
740 +                             if select.index > last_indent {
741 +                                 select.index -= after_whitespace - last_indent;
742 +                             }
743 +                         }
744 +                     }
    |

Check warning on line 670 in src/edit/editor.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`

warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
   --> src/edit/editor.rs:661:21
    |
661 | /                     match self.select_opt {
662 | |                         Some(ref mut select) => {
663 | |                             if select.line == line_i {
664 | |                                 if select.index >= after_whitespace {
...   |
669 | |                         None => {}
670 | |                     }
    | |_____________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
    = note: `#[warn(clippy::single_match)]` on by default
help: try
    |
661 ~                     if let Some(ref mut select) = self.select_opt {
662 +                         if select.line == line_i {
663 +                             if select.index >= after_whitespace {
664 +                                 select.index += required_indent;
665 +                             }
666 +                         }
667 +                     }
    |

Check warning on line 225 in src/buffer_line.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

docs for function which may panic missing `# Panics` section

warning: docs for function which may panic missing `# Panics` section
   --> src/buffer_line.rs:218:5
    |
218 | /     pub fn layout_in_buffer(
219 | |         &mut self,
220 | |         scratch: &mut ShapeBuffer,
221 | |         font_system: &mut FontSystem,
...   |
224 | |         wrap: Wrap,
225 | |     ) -> &[LayoutLine] {
    | |______________________^
    |
note: first possible panic found here
   --> src/buffer_line.rs:234:9
    |
234 |         self.layout_opt.as_ref().expect("layout not found")
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc

Check warning on line 206 in src/buffer_line.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

docs for function which may panic missing `# Panics` section

warning: docs for function which may panic missing `# Panics` section
   --> src/buffer_line.rs:200:5
    |
200 | /     pub fn layout(
201 | |         &mut self,
202 | |         font_system: &mut FontSystem,
203 | |         font_size: f32,
204 | |         width: f32,
205 | |         wrap: Wrap,
206 | |     ) -> &[LayoutLine] {
    | |______________________^
    |
note: first possible panic found here
   --> src/buffer_line.rs:214:9
    |
214 |         self.layout_opt.as_ref().expect("layout not found")
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc

Check warning on line 180 in src/buffer_line.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

docs for function which may panic missing `# Panics` section

warning: docs for function which may panic missing `# Panics` section
   --> src/buffer_line.rs:176:5
    |
176 | /     pub fn shape_in_buffer(
177 | |         &mut self,
178 | |         scratch: &mut ShapeBuffer,
179 | |         font_system: &mut FontSystem,
180 | |     ) -> &ShapeLine {
    | |___________________^
    |
note: first possible panic found here
   --> src/buffer_line.rs:191:9
    |
191 |         self.shape_opt.as_ref().expect("shape not found")
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc

Check warning on line 494 in src/buffer.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

docs for function which may panic missing `# Panics` section

warning: docs for function which may panic missing `# Panics` section
   --> src/buffer.rs:494:5
    |
494 |     pub fn layout_cursor(&self, cursor: &Cursor) -> LayoutCursor {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: first possible panic found here
   --> src/buffer.rs:498:22
    |
498 |         let layout = line.layout_opt().as_ref().expect("layout not found");
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc

Check warning on line 137 in src/buffer.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

docs for function which may panic missing `# Panics` section

warning: docs for function which may panic missing `# Panics` section
   --> src/buffer.rs:137:5
    |
137 |     pub fn highlight(&self, cursor_start: Cursor, cursor_end: Cursor) -> Option<(f32, f32)> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: first possible panic found here
   --> src/buffer.rs:159:25
    |
159 |             let x_end = x_end.expect("end of cursor not found");
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc

Check warning on line 93 in src/buffer.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this `impl` can be derived

warning: this `impl` can be derived
  --> src/buffer.rs:89:1
   |
89 | / impl Default for Affinity {
90 | |     fn default() -> Self {
91 | |         Affinity::Before
92 | |     }
93 | | }
   | |_^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derivable_impls
   = note: `#[warn(clippy::derivable_impls)]` on by default
   = help: remove the manual implementation...
help: ...and instead derive it...
   |
58 + #[derive(Default)]
59 | pub enum Affinity {
   |
help: ...and mark the default variant
   |
59 ~     #[default]
60 ~     Before,
   |

Check warning on line 272 in src/attrs.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

docs for function which may panic missing `# Panics` section

warning: docs for function which may panic missing `# Panics` section
   --> src/attrs.rs:272:5
    |
272 |     pub fn split_off(&mut self, index: usize) -> Self {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: first possible panic found here
   --> src/attrs.rs:288:34
    |
288 |               let (range, attrs) = self
    |  __________________________________^
289 | |                 .spans
290 | |                 .get_key_value(&key.start)
291 | |                 .map(|v| (v.0.clone(), v.1.clone()))
292 | |                 .expect("attrs span not found");
    | |_______________________________________________^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc
note: the lint level is defined here
   --> src/lib.rs:88:9
    |
88  | #![warn(clippy::missing_panics_doc)]
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^

Check warning on line 75 in src/edit/vi.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

method `search` is never used

warning: method `search` is never used
  --> src/edit/vi.rs:75:8
   |
21 | impl<'a> ViEditor<'a> {
   | --------------------- method in this implementation
...
75 |     fn search(&mut self, inverted: bool) {
   |        ^^^^^^

Check warning on line 18 in src/edit/vi.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

field `search_opt` is never read

warning: field `search_opt` is never read
  --> src/edit/vi.rs:18:5
   |
14 | pub struct ViEditor<'a> {
   |            -------- field in this struct
...
18 |     search_opt: Option<(String, bool)>,
   |     ^^^^^^^^^^
   |
   = note: `ViEditor` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
   = note: `#[warn(dead_code)]` on by default

Check warning on line 353 in src/edit/vi.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

unused variable: `char`

warning: unused variable: `char`
   --> src/edit/vi.rs:353:32
    |
353 |                 Event::Replace(char) => {
    |                                ^^^^ help: if this is intentional, prefix it with an underscore: `_char`

Check warning on line 206 in src/edit/vi.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

unused variable: `text_object_opt`

warning: unused variable: `text_object_opt`
   --> src/edit/vi.rs:206:58
    |
206 |                 Event::Operator(count, operator, motion, text_object_opt) => {
    |                                                          ^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_text_object_opt`

Check warning on line 206 in src/edit/vi.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

unused variable: `operator`

warning: unused variable: `operator`
   --> src/edit/vi.rs:206:40
    |
206 |                 Event::Operator(count, operator, motion, text_object_opt) => {
    |                                        ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_operator`
    |
    = note: `#[warn(unused_variables)]` on by default

Check warning on line 1260 in src/shape.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this `else { if .. }` block can be collapsed

warning: this `else { if .. }` block can be collapsed
    --> src/shape.rs:1254:24
     |
1254 |                   } else {
     |  ________________________^
1255 | |                     if self.rtl {
1256 | |                         start_x - x
1257 | |                     } else {
1258 | |                         x
1259 | |                     }
1260 | |                 },
     | |_________________^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_else_if
     = note: `#[warn(clippy::collapsible_else_if)]` on by default
help: collapse nested if block
     |
1254 ~                 } else if self.rtl {
1255 +                     start_x - x
1256 +                 } else {
1257 +                     x
1258 ~                 },
     |

Check warning on line 3 in src/edit/vi.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

unused import: `Operator`

warning: unused import: `Operator`
 --> src/edit/vi.rs:3:28
  |
3 | use modit::{Event, Motion, Operator, Parser, WordIter};
  |                            ^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

Check warning on line 744 in src/edit/editor.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this `if` statement can be collapsed

warning: this `if` statement can be collapsed
   --> src/edit/editor.rs:740:29
    |
740 | / ...                   if select.line == line_i {
741 | | ...                       if select.index > last_indent {
742 | | ...                           select.index -= after_whitespace - last_indent;
743 | | ...                       }
744 | | ...                   }
    | |_______________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
740 ~                             if select.line == line_i && select.index > last_indent {
741 +                                 select.index -= after_whitespace - last_indent;
742 +                             }
    |

Check warning on line 735 in src/edit/editor.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this `if` statement can be collapsed

warning: this `if` statement can be collapsed
   --> src/edit/editor.rs:730:21
    |
730 | /                     if self.cursor.line == line_i {
731 | |                         if self.cursor.index > last_indent {
732 | |                             self.cursor.index -= after_whitespace - last_indent;
733 | |                             self.cursor_moved = true;
734 | |                         }
735 | |                     }
    | |_____________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
730 ~                     if self.cursor.line == line_i && self.cursor.index > last_indent {
731 +                         self.cursor.index -= after_whitespace - last_indent;
732 +                         self.cursor_moved = true;
733 +                     }
    |

Check warning on line 667 in src/edit/editor.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this `if` statement can be collapsed

warning: this `if` statement can be collapsed
   --> src/edit/editor.rs:663:29
    |
663 | / ...                   if select.line == line_i {
664 | | ...                       if select.index >= after_whitespace {
665 | | ...                           select.index += required_indent;
666 | | ...                       }
667 | | ...                   }
    | |_______________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
663 ~                             if select.line == line_i && select.index >= after_whitespace {
664 +                                 select.index += required_indent;
665 +                             }
    |

Check warning on line 658 in src/edit/editor.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this `if` statement can be collapsed

warning: this `if` statement can be collapsed
   --> src/edit/editor.rs:653:21
    |
653 | /                     if self.cursor.line == line_i {
654 | |                         if self.cursor.index >= after_whitespace {
655 | |                             self.cursor.index += required_indent;
656 | |                             self.cursor_moved = true;
657 | |                         }
658 | |                     }
    | |_____________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
    = note: `#[warn(clippy::collapsible_if)]` on by default
help: collapse nested if block
    |
653 ~                     if self.cursor.line == line_i && self.cursor.index >= after_whitespace {
654 +                         self.cursor.index += required_indent;
655 +                         self.cursor_moved = true;
656 +                     }
    |

Check warning on line 67 in src/lib.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

lint `clippy::integer_arithmetic` has been renamed to `clippy::arithmetic_side_effects`

warning: lint `clippy::integer_arithmetic` has been renamed to `clippy::arithmetic_side_effects`
  --> src/lib.rs:67:10
   |
67 | #![allow(clippy::integer_arithmetic)]
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::arithmetic_side_effects`
   |
   = note: `#[warn(renamed_and_removed_lints)]` on by default