mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
Use a lot more let-else (#7582)
This commit is contained in:
@@ -239,17 +239,17 @@ impl FontImpl {
|
||||
return None; // these will result in the replacement character when rendering
|
||||
}
|
||||
|
||||
if c == '\t' {
|
||||
if let Some(space) = self.glyph_info(' ') {
|
||||
let glyph_info = GlyphInfo {
|
||||
advance_width_unscaled: (crate::text::TAB_SIZE as f32
|
||||
* space.advance_width_unscaled.0)
|
||||
.into(),
|
||||
..space
|
||||
};
|
||||
self.glyph_info_cache.insert(c, glyph_info);
|
||||
return Some(glyph_info);
|
||||
}
|
||||
if c == '\t'
|
||||
&& let Some(space) = self.glyph_info(' ')
|
||||
{
|
||||
let glyph_info = GlyphInfo {
|
||||
advance_width_unscaled: (crate::text::TAB_SIZE as f32
|
||||
* space.advance_width_unscaled.0)
|
||||
.into(),
|
||||
..space
|
||||
};
|
||||
self.glyph_info_cache.insert(c, glyph_info);
|
||||
return Some(glyph_info);
|
||||
}
|
||||
|
||||
if c == '\u{2009}' {
|
||||
|
||||
@@ -113,13 +113,11 @@ pub fn layout(fonts: &mut FontsImpl, pixels_per_point: f32, job: Arc<LayoutJob>)
|
||||
|
||||
let mut elided = false;
|
||||
let mut rows = rows_from_paragraphs(paragraphs, &job, &mut elided);
|
||||
if elided {
|
||||
if let Some(last_placed) = rows.last_mut() {
|
||||
let last_row = Arc::make_mut(&mut last_placed.row);
|
||||
replace_last_glyph_with_overflow_character(fonts, pixels_per_point, &job, last_row);
|
||||
if let Some(last) = last_row.glyphs.last() {
|
||||
last_row.size.x = last.max_x();
|
||||
}
|
||||
if elided && let Some(last_placed) = rows.last_mut() {
|
||||
let last_row = Arc::make_mut(&mut last_placed.row);
|
||||
replace_last_glyph_with_overflow_character(fonts, pixels_per_point, &job, last_row);
|
||||
if let Some(last) = last_row.glyphs.last() {
|
||||
last_row.size.x = last.max_x();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -957,15 +957,15 @@ impl Galley {
|
||||
// Vertical margin around galley improves text selection UX
|
||||
const VMARGIN: f32 = 5.0;
|
||||
|
||||
if let Some(first_row) = self.rows.first() {
|
||||
if pos.y < first_row.min_y() - VMARGIN {
|
||||
return self.begin();
|
||||
}
|
||||
if let Some(first_row) = self.rows.first()
|
||||
&& pos.y < first_row.min_y() - VMARGIN
|
||||
{
|
||||
return self.begin();
|
||||
}
|
||||
if let Some(last_row) = self.rows.last() {
|
||||
if last_row.max_y() + VMARGIN < pos.y {
|
||||
return self.end();
|
||||
}
|
||||
if let Some(last_row) = self.rows.last()
|
||||
&& last_row.max_y() + VMARGIN < pos.y
|
||||
{
|
||||
return self.end();
|
||||
}
|
||||
|
||||
let mut best_y_dist = f32::INFINITY;
|
||||
|
||||
Reference in New Issue
Block a user