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

Add line ending abstraction #250

Merged
merged 3 commits into from
Apr 30, 2024

Add ctrl+s for saving to editor

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

Add line ending abstraction #250

Add ctrl+s for saving to editor
2f467d8
Select commit
Loading
Failed to load commit list.
GitHub Actions / clippy succeeded Apr 30, 2024 in 1s

clippy

24 warnings

Details

Results

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

Versions

  • rustc 1.77.2 (25ef9e3d8 2024-04-09)
  • cargo 1.77.2 (e52e36006 2024-03-26)
  • clippy 0.1.77 (25ef9e3 2024-04-09)

Annotations

Check warning on line 36 in src/shape_run_cache.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/shape_run_cache.rs:36:61
   |
36 |     /// Remove anything in the cache with an age older than keep_ages
   |                                                             ^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
help: try
   |
36 |     /// Remove anything in the cache with an age older than `keep_ages`
   |                                                             ~~~~~~~~~~~

Check warning on line 378 in src/shape.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

manual saturating arithmetic

warning: manual saturating arithmetic
   --> src/shape.rs:376:19
    |
376 |           let end = min(attrs_range.end, end_run)
    |  ___________________^
377 | |             .checked_sub(start_run)
378 | |             .unwrap_or(0);
    | |_________________________^ help: consider using `saturating_sub`: `min(attrs_range.end, end_run).saturating_sub(start_run)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_saturating_arithmetic

Check warning on line 375 in src/shape.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

manual saturating arithmetic

warning: manual saturating arithmetic
   --> src/shape.rs:373:21
    |
373 |           let start = max(attrs_range.start, start_run)
    |  _____________________^
374 | |             .checked_sub(start_run)
375 | |             .unwrap_or(0);
    | |_________________________^ help: consider using `saturating_sub`: `max(attrs_range.start, start_run).saturating_sub(start_run)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_saturating_arithmetic
    = note: `#[warn(clippy::manual_saturating_arithmetic)]` on by default

Check warning on line 66 in src/line_ending.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

single-character string constant used as pattern

warning: single-character string constant used as pattern
  --> src/line_ending.rs:66:45
   |
66 |                 } else if after.starts_with("\r") {
   |                                             ^^^^ help: consider using a `char`: `'\r'`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_pattern

Check warning on line 64 in src/line_ending.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

single-character string constant used as pattern

warning: single-character string constant used as pattern
  --> src/line_ending.rs:64:45
   |
64 |                 } else if after.starts_with("\n") {
   |                                             ^^^^ help: consider using a `char`: `'\n'`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_pattern
   = note: `#[warn(clippy::single_char_pattern)]` on by default

Check warning on line 55 in src/line_ending.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

the borrowed expression implements the required traits

warning: the borrowed expression implements the required traits
  --> src/line_ending.rs:55:49
   |
55 |         match self.string[start..self.end].find(&['\r', '\n']) {
   |                                                 ^^^^^^^^^^^^^ help: change this to: `['\r', '\n']`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args
   = note: `#[warn(clippy::needless_borrows_for_generic_args)]` on by default

Check warning on line 293 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:293:56
    |
293 |     /// Insert text at specified cursor with specified attrs_list
    |                                                        ^^^^^^^^^^
    |
    = 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
    |
293 |     /// Insert text at specified cursor with specified `attrs_list`
    |                                                        ~~~~~~~~~~~~

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

See this annotation in the file changed.

@github-actions github-actions / clippy

consider adding a `;` to the last statement for consistent formatting

warning: consider adding a `;` to the last statement for consistent formatting
   --> src/edit/mod.rs:190:9
    |
190 |         self.with_buffer_mut(|buffer| buffer.set_redraw(redraw))
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `self.with_buffer_mut(|buffer| buffer.set_redraw(redraw));`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned

Check warning on line 1171 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:1167:5
     |
1167 | /     pub fn load_text<P: AsRef<std::path::Path>>(
1168 | |         &mut self,
1169 | |         path: P,
1170 | |         attrs: crate::Attrs,
1171 | |     ) -> 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 1138 in src/edit/vi.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

manual implementation of `Option::map`

warning: manual implementation of `Option::map`
    --> src/edit/vi.rs:1132:37
     |
1132 | / ...                   if let Some(last) = layout_runs.last() {
1133 | | ...                       Some(Action::Motion(Motion::GotoLine(
1134 | | ...                           (last.line_i + first.line_i) / 2,
1135 | | ...                       )))
1136 | | ...                   } else {
1137 | | ...                       None
1138 | | ...                   }
     | |_______________________^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_map
     = note: `#[warn(clippy::manual_map)]` on by default
help: try
     |
1132 ~                                     layout_runs.last().map(|last| Action::Motion(Motion::GotoLine(
1133 +                                             (last.line_i + first.line_i) / 2,
1134 +                                         )))
     |

Check warning on line 1022 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:1005:37
     |
1005 | / ...                   match text[..cursor.index]
1006 | | ...                       .char_indices()
1007 | | ...                       .filter_map(|(i, c)| {
1008 | | ...                           if c == find_c {
...    |
1021 | | ...                       None => {}
1022 | | ...                   }
     | |_______________________^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
help: try
     |
1005 ~                                     if let Some(i) = text[..cursor.index]
1006 +                                         .char_indices()
1007 +                                         .filter_map(|(i, c)| {
1008 +                                             if c == find_c {
1009 +                                                 let end = i + c.len_utf8();
1010 +                                                 if end < cursor.index {
1011 +                                                     return Some(end);
1012 +                                                 }
1013 +                                             }
1014 +                                             None
1015 +                                         })
1016 +                                         .last() {
1017 +                                         cursor.index = i;
1018 +                                     }
     |

Check warning on line 994 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:985:37
    |
985 | / ...                   match text[..cursor.index]
986 | | ...                       .char_indices()
987 | | ...                       .filter(|&(_, c)| c == find_c)
988 | | ...                       .last()
...   |
993 | | ...                       None => {}
994 | | ...                   }
    | |_______________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
help: try
    |
985 ~                                     if let Some((i, _)) = text[..cursor.index]
986 +                                         .char_indices()
987 +                                         .filter(|&(_, c)| c == find_c)
988 +                                         .last() {
989 +                                         cursor.index = i;
990 +                                     }
    |

Check warning on line 882 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:879:43
    |
879 |   ...                   match text[cursor.index..]
    |  _____________________________^
880 | | ...                       .char_indices()
881 | | ...                       .filter(|&(i, c)| i > 0 && c == find_c)
882 | | ...                       .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
    |
879 ~                                     match text[cursor.index..]
880 +                                         .char_indices().find(|&(i, c)| i > 0 && c == find_c)
    |

Check warning on line 888 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:879:37
    |
879 | / ...                   match text[cursor.index..]
880 | | ...                       .char_indices()
881 | | ...                       .filter(|&(i, c)| i > 0 && c == find_c)
882 | | ...                       .next()
...   |
887 | | ...                       None => {}
888 | | ...                   }
    | |_______________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
help: try
    |
879 ~                                     if let Some((i, _)) = text[cursor.index..]
880 +                                         .char_indices()
881 +                                         .filter(|&(i, c)| i > 0 && c == find_c)
882 +                                         .next() {
883 +                                         cursor.index += i;
884 +                                     }
    |

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

See this annotation in the file changed.

@github-actions github-actions / clippy

match expression looks like `matches!` macro

warning: match expression looks like `matches!` macro
   --> src/edit/vi.rs:645:29
    |
645 |           let has_selection = match editor.selection() {
    |  _____________________________^
646 | |             Selection::None => false,
647 | |             _ => true,
648 | |         };
    | |_________^ help: try: `!matches!(editor.selection(), Selection::None)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro
    = note: `#[warn(clippy::match_like_matches_macro)]` on by default

Check warning on line 218 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:213:5
    |
213 | /     pub fn load_text<P: AsRef<std::path::Path>>(
214 | |         &mut self,
215 | |         font_system: &mut FontSystem,
216 | |         path: P,
217 | |         attrs: crate::Attrs,
218 | |     ) -> 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 128 in src/edit/syntect.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

consider adding a `;` to the last statement for consistent formatting

warning: consider adding a `;` to the last statement for consistent formatting
   --> src/edit/syntect.rs:128:13
    |
128 |             buffer.set_text(font_system, &text, attrs, Shaping::Advanced)
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `buffer.set_text(font_system, &text, attrs, Shaping::Advanced);`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
note: the lint level is defined here
   --> src/lib.rs:90:9
    |
90  | #![warn(clippy::semicolon_if_nothing_returned)]
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Check warning on line 531 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:521:9
    |
521 | /         match self.change.take() {
522 | |             Some(pending) => {
523 | |                 if !pending.items.is_empty() {
524 | |                     //TODO: is this a good idea?
...   |
530 | |             None => {}
531 | |         }
    | |_________^
    |
    = 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
    |
521 ~         if let Some(pending) = self.change.take() {
522 +             if !pending.items.is_empty() {
523 +                 //TODO: is this a good idea?
524 +                 log::warn!("pending change caused apply_change to be ignored!");
525 +                 self.change = Some(pending);
526 +                 return false;
527 +             }
528 +         }
    |

Check warning on line 241 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:233:5
    |
233 | /     pub fn layout_in_buffer(
234 | |         &mut self,
235 | |         scratch: &mut ShapeBuffer,
236 | |         font_system: &mut FontSystem,
...   |
240 | |         match_mono_width: Option<f32>,
241 | |     ) -> &[LayoutLine] {
    | |______________________^
    |
note: first possible panic found here
   --> src/buffer_line.rs:257:9
    |
257 |         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 194 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:190:5
    |
190 | /     pub fn shape_in_buffer(
191 | |         &mut self,
192 | |         scratch: &mut ShapeBuffer,
193 | |         font_system: &mut FontSystem,
194 | |     ) -> &ShapeLine {
    | |___________________^
    |
note: first possible panic found here
   --> src/buffer_line.rs:205:9
    |
205 |         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 379 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:379:5
    |
379 |     pub fn shape_until_scroll(&mut self, font_system: &mut FontSystem, prune: bool) {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: first possible panic found here
   --> src/buffer.rs:417:30
    |
417 |                   let layout = self
    |  ______________________________^
418 | |                     .line_layout(font_system, line_i)
419 | |                     .expect("shape_until_scroll invalid line");
    | |______________________________________________________________^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc

Check warning on line 336 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:331:5
    |
331 | /     pub fn shape_until_cursor(
332 | |         &mut self,
333 | |         font_system: &mut FontSystem,
334 | |         cursor: Cursor,
335 | |         prune: bool,
336 | |     ) {
    | |_____^
    |
note: first possible panic found here
   --> src/buffer.rs:339:29
    |
339 |           let layout_cursor = self
    |  _____________________________^
340 | |             .layout_cursor(font_system, cursor)
341 | |             .expect("shape_until_cursor invalid cursor");
    | |________________________________________________________^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc

Check warning on line 38 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:38:5
   |
38 |     pub fn highlight(&self, cursor_start: Cursor, cursor_end: Cursor) -> Option<(f32, f32)> {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: first possible panic found here
  --> src/buffer.rs:60:25
   |
60 |             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 303 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:303:5
    |
303 |     pub fn split_off(&mut self, index: usize) -> Self {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: first possible panic found here
   --> src/attrs.rs:319:34
    |
319 |               let (range, attrs) = self
    |  __________________________________^
320 | |                 .spans
321 | |                 .get_key_value(&key.start)
322 | |                 .map(|v| (v.0.clone(), v.1.clone()))
323 | |                 .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)]
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^