Revert "fix(clippy): clippy::manual_clamp" (#1817)

* Revert "fix(clippy): clippy::manual_clamp"

This reverts commit d8c76be3e1.

* fix(clippy): #![allow(clippy::manual_clamp)]
This commit is contained in:
Jakub Panek 2022-12-16 23:37:14 +01:00 committed by GitHub
parent d808078b21
commit 19cefff16d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 26 additions and 15 deletions

View File

@ -1,3 +1,5 @@
#![allow(clippy::manual_clamp)]
pub mod buffer;
pub mod chars;
pub mod command;

View File

@ -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)
}
}

View File

@ -1,3 +1,5 @@
#![allow(clippy::manual_clamp)]
pub mod about;
pub mod alert;
pub mod atomic_soft_tabs;

View File

@ -1,3 +1,5 @@
#![allow(clippy::manual_clamp)]
pub mod buffer;
pub mod dispatch;
pub mod plugin;

View File

@ -1,3 +1,5 @@
#![allow(clippy::manual_clamp)]
pub mod buffer;
pub mod core;
pub mod counter;

View File

@ -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)

View File

@ -1,3 +1,5 @@
#![allow(clippy::manual_clamp)]
pub mod about;
pub mod alert;
pub mod app;

View File

@ -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)
}

View File

@ -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

View File

@ -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 {

View File

@ -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)),