Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vi editor improvements #198

Merged
merged 47 commits into from
Nov 17, 2023

Merge remote-tracking branch 'origin/main' into vi-editor

66a6803
Select commit
Loading
Failed to load commit list.
Sign in for the full log view
Merged

Vi editor improvements #198

Merge remote-tracking branch 'origin/main' into vi-editor
66a6803
Select commit
Loading
Failed to load commit list.
This check has been archived and is scheduled for deletion. Learn more about checks retention
GitHub Actions / clippy succeeded Nov 17, 2023 in 1s

clippy

14 warnings

Details

Results

Message level Amount
Internal compiler error 0
Error 0
Warning 14
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 983 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:979:5
    |
979 | /     pub fn load_text<P: AsRef<std::path::Path>>(
980 | |         &mut self,
981 | |         path: P,
982 | |         attrs: crate::Attrs,
983 | |     ) -> 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 636 in src/edit/vi.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/vi.rs:618:33
    |
618 | / ...                   match text[..cursor.index]
619 | | ...                       .char_indices()
620 | | ...                       .filter_map(|(i, c)| {
621 | | ...                           if c == find_c {
...   |
635 | | ...                       None => {}
636 | | ...                   }
    | |_______________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
help: try
    |
618 ~                                 if let Some(i) = text[..cursor.index]
619 +                                     .char_indices()
620 +                                     .filter_map(|(i, c)| {
621 +                                         if c == find_c {
622 +                                             let end = i + c.len_utf8();
623 +                                             if end < cursor.index {
624 +                                                 return Some(end);
625 +                                             }
626 +                                         }
627 +                                         None
628 +                                     })
629 +                                     .last() {
630 +                                     cursor.index = i;
631 +                                     editor.set_cursor(cursor);
632 +                                 }
    |

Check warning on line 609 in src/edit/vi.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/vi.rs:599:33
    |
599 | / ...                   match text[..cursor.index]
600 | | ...                       .char_indices()
601 | | ...                       .filter(|&(_, c)| c == find_c)
602 | | ...                       .last()
...   |
608 | | ...                       None => {}
609 | | ...                   }
    | |_______________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
help: try
    |
599 ~                                 if let Some((i, _)) = text[..cursor.index]
600 +                                     .char_indices()
601 +                                     .filter(|&(_, c)| c == find_c)
602 +                                     .last() {
603 +                                     cursor.index = i;
604 +                                     editor.set_cursor(cursor);
605 +                                 }
    |

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

See this annotation in the file changed.

@github-actions github-actions / clippy

called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead

warning: called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead
   --> src/edit/vi.rs:501:39
    |
501 |   ...                   match text[cursor.index..]
    |  _____________________________^
502 | | ...                       .char_indices()
503 | | ...                       .filter(|&(i, c)| i > 0 && c == find_c)
504 | | ...                       .next()
    | |_________________________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#filter_next
    = note: `#[warn(clippy::filter_next)]` on by default
help: try
    |
501 ~                                 match text[cursor.index..]
502 +                                     .char_indices().find(|&(i, c)| i > 0 && c == find_c)
    |

Check warning on line 511 in src/edit/vi.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/vi.rs:501:33
    |
501 | / ...                   match text[cursor.index..]
502 | | ...                       .char_indices()
503 | | ...                       .filter(|&(i, c)| i > 0 && c == find_c)
504 | | ...                       .next()
...   |
510 | | ...                       None => {}
511 | | ...                   }
    | |_______________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
help: try
    |
501 ~                                 if let Some((i, _)) = text[cursor.index..]
502 +                                     .char_indices()
503 +                                     .filter(|&(i, c)| i > 0 && c == find_c)
504 +                                     .next() {
505 +                                     cursor.index += i;
506 +                                     editor.set_cursor(cursor);
507 +                                 }
    |

Check warning on line 187 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:182:5
    |
182 | /     pub fn load_text<P: AsRef<std::path::Path>>(
183 | |         &mut self,
184 | |         font_system: &mut FontSystem,
185 | |         path: P,
186 | |         attrs: crate::Attrs,
187 | |     ) -> 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 41 in src/edit/vi.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/vi.rs:33:5
   |
33 | /     match editor.finish_change() {
34 | |         Some(change) => {
35 | |             if !change.items.is_empty() {
36 | |                 commands.push(change);
...  |
40 | |         None => {}
41 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
help: try
   |
33 ~     if let Some(change) = editor.finish_change() {
34 +         if !change.items.is_empty() {
35 +             commands.push(change);
36 +             *changed = true;
37 +         }
38 +     }
   |

Check warning on line 386 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:376:9
    |
376 | /         match self.change.take() {
377 | |             Some(pending) => {
378 | |                 if !pending.items.is_empty() {
379 | |                     //TODO: is this a good idea?
...   |
385 | |             None => {}
386 | |         }
    | |_________^
    |
    = 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
    |
376 ~         if let Some(pending) = self.change.take() {
377 +             if !pending.items.is_empty() {
378 +                 //TODO: is this a good idea?
379 +                 log::warn!("pending change caused apply_change to be ignored!");
380 +                 self.change = Some(pending);
381 +                 return false;
382 +             }
383 +         }
    |

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 486 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:486:5
    |
486 |     pub fn layout_cursor(&self, cursor: &Cursor) -> LayoutCursor {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: first possible panic found here
   --> src/buffer.rs:490:22
    |
490 |         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 129 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:129:5
    |
129 |     pub fn highlight(&self, cursor_start: Cursor, cursor_end: Cursor) -> Option<(f32, f32)> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: first possible panic found here
   --> src/buffer.rs:151:25
    |
151 |             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 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)]
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^