diff --git a/lapce-core/src/lib.rs b/lapce-core/src/lib.rs index 350a8130..b1bb54cb 100644 --- a/lapce-core/src/lib.rs +++ b/lapce-core/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::manual_clamp)] + pub mod buffer; pub mod chars; pub mod command; diff --git a/lapce-data/src/config.rs b/lapce-data/src/config.rs index 8254f8d7..f8919fa7 100644 --- a/lapce-data/src/config.rs +++ b/lapce-data/src/config.rs @@ -548,14 +548,14 @@ pub fn font_family(&self) -> FontFamily { } pub fn font_size(&self) -> usize { - self.font_size.clamp(6, 32) + self.font_size.max(6).min(32) } pub fn icon_size(&self) -> usize { if self.icon_size == 0 { self.font_size() + 2 } else { - self.icon_size.clamp(6, 32) + self.icon_size.max(6).min(32) } } diff --git a/lapce-data/src/lib.rs b/lapce-data/src/lib.rs index 1a8cf1fc..bcdcf52a 100644 --- a/lapce-data/src/lib.rs +++ b/lapce-data/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::manual_clamp)] + pub mod about; pub mod alert; pub mod atomic_soft_tabs; diff --git a/lapce-proxy/src/lib.rs b/lapce-proxy/src/lib.rs index b063d4f2..eb7f537c 100644 --- a/lapce-proxy/src/lib.rs +++ b/lapce-proxy/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::manual_clamp)] + pub mod buffer; pub mod dispatch; pub mod plugin; diff --git a/lapce-rpc/src/lib.rs b/lapce-rpc/src/lib.rs index 5d4c230a..a4501564 100644 --- a/lapce-rpc/src/lib.rs +++ b/lapce-rpc/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::manual_clamp)] + pub mod buffer; pub mod core; pub mod counter; diff --git a/lapce-ui/src/editor.rs b/lapce-ui/src/editor.rs index 0673042a..fb7f33e4 100644 --- a/lapce-ui/src/editor.rs +++ b/lapce-ui/src/editor.rs @@ -1263,7 +1263,7 @@ fn paint_cursor_new( .doc .buffer() .offset_to_line_col(end_offset); - end_col.clamp(start_col, max_col) + end_col.max(start_col).min(max_col) } }; (right, false) diff --git a/lapce-ui/src/lib.rs b/lapce-ui/src/lib.rs index 5f1643fa..ec26c347 100644 --- a/lapce-ui/src/lib.rs +++ b/lapce-ui/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::manual_clamp)] + pub mod about; pub mod alert; pub mod app; diff --git a/lapce-ui/src/scroll.rs b/lapce-ui/src/scroll.rs index cf04b664..4792dfef 100644 --- a/lapce-ui/src/scroll.rs +++ b/lapce-ui/src/scroll.rs @@ -58,10 +58,12 @@ impl Viewport { pub fn clamp_view_origin(&self, origin: Point) -> Point { let x = origin .x - .clamp(0.0, self.content_size.width - self.rect.width()); + .min(self.content_size.width - self.rect.width()) + .max(0.0); let y = origin .y - .clamp(0.0, self.content_size.height - self.rect.height()); + .min(self.content_size.height - self.rect.height()) + .max(0.0); Point::new(x, y) } diff --git a/lapce-ui/src/split.rs b/lapce-ui/src/split.rs index c271daff..6091dc9e 100644 --- a/lapce-ui/src/split.rs +++ b/lapce-ui/src/split.rs @@ -428,14 +428,13 @@ fn shift_start_of_child(&mut self, i: usize, start: f64, allow_shifting: bool) { let start = if allow_shifting && start <= prev_limit { // If the start is before the previous offset, then we can start moving the previous editor - start.clamp(limit_margin * i as f64, next_limit) + start.max(limit_margin * i as f64).min(next_limit) } else if allow_shifting && start >= next_limit { - start.clamp( - prev_limit, - flex_total - limit_margin * (self.children.len() - i) as f64, - ) + start + .max(prev_limit) + .min(flex_total - limit_margin * (self.children.len() - i) as f64) } else { - start.clamp(prev_limit, next_limit) + start.max(prev_limit).min(next_limit) }; // Check if we're shifting a specific previous child diff --git a/lapce-ui/src/tab.rs b/lapce-ui/src/tab.rs index b42702a6..9d17c38c 100644 --- a/lapce-ui/src/tab.rs +++ b/lapce-ui/src/tab.rs @@ -219,7 +219,7 @@ fn update_split_point( PanelResizePosition::Left => { let maximum = self.width - 100.0 - data.panel.size.right; Arc::make_mut(&mut data.panel).size.left = - mouse_pos.x.round().clamp(180.0, maximum); + mouse_pos.x.round().max(180.0).min(maximum); if mouse_pos.x < 90.0 { if data .panel @@ -256,7 +256,7 @@ fn update_split_point( let maximum = self.width - 100.0 - data.panel.size.left; let right = self.width - mouse_pos.x.round(); Arc::make_mut(&mut data.panel).size.right = - right.clamp(180.0, maximum); + right.max(180.0).min(maximum); if right < 90.0 { if data .panel @@ -303,7 +303,7 @@ fn update_split_point( - 1.0; Arc::make_mut(&mut data.panel).size.bottom = - bottom.clamp(180.0, minimum); + bottom.max(180.0).min(minimum); // Check if it should snap the bottom panel away, if you are too low if bottom < 90.0 { diff --git a/lapce-ui/src/title.rs b/lapce-ui/src/title.rs index 0c820642..ef699556 100644 --- a/lapce-ui/src/title.rs +++ b/lapce-ui/src/title.rs @@ -813,7 +813,7 @@ fn layout( } else { 300.0 }; - let palette_width = remaining.clamp(min_palette_width, 500.0); + let palette_width = remaining.min(500.0).max(min_palette_width); let palette_size = self.palette.layout( ctx, &BoxConstraints::tight(Size::new(palette_width, bc.max().height)),