resolve all lints, update MSRV
This commit is contained in:
parent
166b59f560
commit
f05a69a9d9
18 changed files with 251 additions and 283 deletions
|
|
@ -32,11 +32,12 @@ pub struct LayoutRun<'a> {
|
|||
pub line_w: f32,
|
||||
}
|
||||
|
||||
impl<'a> LayoutRun<'a> {
|
||||
impl LayoutRun<'_> {
|
||||
/// Return the pixel span `Some((x_left, x_width))` of the highlighted area between `cursor_start`
|
||||
/// and `cursor_end` within this run, or None if the cursor range does not intersect this run.
|
||||
/// This may return widths of zero if `cursor_start == cursor_end`, if the run is empty, or if the
|
||||
/// region's left start boundary is the same as the cursor's end boundary or vice versa.
|
||||
#[allow(clippy::missing_panics_doc)]
|
||||
pub fn highlight(&self, cursor_start: Cursor, cursor_end: Cursor) -> Option<(f32, f32)> {
|
||||
let mut x_start = None;
|
||||
let mut x_end = None;
|
||||
|
|
@ -202,7 +203,7 @@ impl fmt::Display for Metrics {
|
|||
/// A buffer of text that is shaped and laid out
|
||||
#[derive(Debug)]
|
||||
pub struct Buffer {
|
||||
/// [BufferLine]s (or paragraphs) of text in the buffer
|
||||
/// [`BufferLine`]s (or paragraphs) of text in the buffer
|
||||
pub lines: Vec<BufferLine>,
|
||||
metrics: Metrics,
|
||||
width_opt: Option<f32>,
|
||||
|
|
@ -305,6 +306,7 @@ impl Buffer {
|
|||
}
|
||||
|
||||
/// Shape lines until cursor, also scrolling to include cursor in view
|
||||
#[allow(clippy::missing_panics_doc)]
|
||||
pub fn shape_until_cursor(
|
||||
&mut self,
|
||||
font_system: &mut FontSystem,
|
||||
|
|
@ -323,11 +325,11 @@ impl Buffer {
|
|||
let layout = self
|
||||
.line_layout(font_system, layout_cursor.line)
|
||||
.expect("shape_until_cursor failed to scroll forwards");
|
||||
for layout_i in 0..layout_cursor.layout {
|
||||
(0..layout_cursor.layout).for_each(|layout_i| {
|
||||
layout_y += layout[layout_i]
|
||||
.line_height_opt
|
||||
.unwrap_or(metrics.line_height);
|
||||
}
|
||||
});
|
||||
layout_y
|
||||
+ layout[layout_cursor.layout]
|
||||
.line_height_opt
|
||||
|
|
@ -403,6 +405,7 @@ impl Buffer {
|
|||
}
|
||||
|
||||
/// Shape lines until scroll
|
||||
#[allow(clippy::missing_panics_doc)]
|
||||
pub fn shape_until_scroll(&mut self, font_system: &mut FontSystem, prune: bool) {
|
||||
let metrics = self.metrics;
|
||||
let old_scroll = self.scroll;
|
||||
|
|
@ -603,10 +606,8 @@ impl Buffer {
|
|||
self.tab_width = tab_width;
|
||||
// Shaping must be reset when tab width is changed
|
||||
for line in self.lines.iter_mut() {
|
||||
if line.shape_opt().is_some() {
|
||||
if line.text().contains('\t') {
|
||||
line.reset_shaping();
|
||||
}
|
||||
if line.shape_opt().is_some() && line.text().contains('\t') {
|
||||
line.reset_shaping();
|
||||
}
|
||||
}
|
||||
self.redraw = true;
|
||||
|
|
@ -1095,7 +1096,7 @@ impl Buffer {
|
|||
layout_cursor.layout -= 1;
|
||||
} else if layout_cursor.line > 0 {
|
||||
layout_cursor.line -= 1;
|
||||
layout_cursor.layout = usize::max_value();
|
||||
layout_cursor.layout = usize::MAX;
|
||||
}
|
||||
|
||||
if let Some(cursor_x) = cursor_x_opt {
|
||||
|
|
@ -1164,7 +1165,7 @@ impl Buffer {
|
|||
}
|
||||
Motion::End => {
|
||||
let mut layout_cursor = self.layout_cursor(font_system, cursor)?;
|
||||
layout_cursor.glyph = usize::max_value();
|
||||
layout_cursor.glyph = usize::MAX;
|
||||
#[allow(unused_assignments)]
|
||||
{
|
||||
(cursor, cursor_x_opt) = self.cursor_motion(
|
||||
|
|
@ -1365,7 +1366,7 @@ impl Buffer {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> BorrowedWithFontSystem<'a, Buffer> {
|
||||
impl BorrowedWithFontSystem<'_, Buffer> {
|
||||
/// Shape lines until cursor, also scrolling to include cursor in view
|
||||
pub fn shape_until_cursor(&mut self, cursor: Cursor, prune: bool) {
|
||||
self.inner
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue