diff --git a/melib/src/text_processing/grapheme_clusters.rs b/melib/src/text_processing/grapheme_clusters.rs index 174b4f5d..3a7e8499 100644 --- a/melib/src/text_processing/grapheme_clusters.rs +++ b/melib/src/text_processing/grapheme_clusters.rs @@ -71,10 +71,16 @@ pub trait TextProcessing: UnicodeSegmentation + CodePointsIter { impl TextProcessing for str { fn split_lines(&self, width: usize) -> Vec { + if width == 0 { + return vec![]; + } super::line_break::linear(self, width) } fn split_lines_reflow(&self, reflow: Reflow, width: Option) -> Vec { + if width == Some(0) { + return vec![]; + } super::line_break::split_lines_reflow(self, reflow, width) } } diff --git a/melib/src/text_processing/line_break.rs b/melib/src/text_processing/line_break.rs index 6c50c5e5..c3209f6f 100644 --- a/melib/src/text_processing/line_break.rs +++ b/melib/src/text_processing/line_break.rs @@ -1023,6 +1023,9 @@ pub fn split_lines_reflow(text: &str, reflow: Reflow, width: Option) -> V ret.push(format!("⤷{}", &line[prev_line_offset..end_offset])); } } + if prev_line_offset == end_offset && prev == new_off { + break; + } prev_line_offset = end_offset; prev = new_off; } diff --git a/src/components/mail/listing/compact.rs b/src/components/mail/listing/compact.rs index 796c47c1..60ebb0d3 100644 --- a/src/components/mail/listing/compact.rs +++ b/src/components/mail/listing/compact.rs @@ -294,6 +294,9 @@ impl ListingTrait for CompactListing { return; } let rows = get_y(bottom_right) - get_y(upper_left) + 1; + if rows == 0 { + return; + } if let Some(mvm) = self.movement.take() { match mvm { diff --git a/src/components/mail/listing/conversations.rs b/src/components/mail/listing/conversations.rs index 3a5283ec..d055dec7 100644 --- a/src/components/mail/listing/conversations.rs +++ b/src/components/mail/listing/conversations.rs @@ -295,6 +295,9 @@ impl ListingTrait for ConversationsListing { return; } let rows = (get_y(bottom_right) - get_y(upper_left) + 1) / 3; + if rows == 0 { + return; + } let pad = (get_y(bottom_right) - get_y(upper_left) + 1) % 3; if let Some(mvm) = self.movement.take() { diff --git a/src/components/mail/listing/plain.rs b/src/components/mail/listing/plain.rs index 83101aa4..3a0652c8 100644 --- a/src/components/mail/listing/plain.rs +++ b/src/components/mail/listing/plain.rs @@ -300,6 +300,9 @@ impl ListingTrait for PlainListing { return; } let rows = get_y(bottom_right) - get_y(upper_left) + 1; + if rows == 0 { + return; + } if let Some(mvm) = self.movement.take() { match mvm { diff --git a/src/components/mail/listing/thread.rs b/src/components/mail/listing/thread.rs index 0006e25a..6156a7e4 100644 --- a/src/components/mail/listing/thread.rs +++ b/src/components/mail/listing/thread.rs @@ -225,6 +225,9 @@ impl ListingTrait for ThreadListing { return; } let rows = get_y(bottom_right) - get_y(upper_left) + 1; + if rows == 0 { + return; + } if let Some(mvm) = self.movement.take() { match mvm { PageMovement::Up(amount) => { diff --git a/src/terminal/position.rs b/src/terminal/position.rs index 06d66d23..bc34c956 100644 --- a/src/terminal/position.rs +++ b/src/terminal/position.rs @@ -57,12 +57,8 @@ pub fn pos_dec(p: Pos, dec: (usize, usize)) -> Pos { /// An `Area` consists of two points: the upper left and bottom right corners. /// /// Example: -/// ``` -/// # #[macro_use] extern crate ui; fn main() { -/// use ui::*; -/// +/// ```no_run /// let new_area = ((0, 0), (1, 1)); -/// # } /// ``` pub type Area = (Pos, Pos); @@ -70,12 +66,8 @@ pub type Area = (Pos, Pos); /// /// Example: /// ``` -/// # #[macro_use] extern crate ui; fn main() { -/// use ui::*; -/// /// let new_area = ((0, 0), (1, 1)); /// assert_eq!(height!(new_area), 1); -/// # } /// ``` #[macro_export] macro_rules! height { @@ -88,12 +80,8 @@ macro_rules! height { /// /// Example: /// ``` -/// # #[macro_use] extern crate ui; fn main() { -/// use ui::*; -/// /// let new_area = ((0, 0), (1, 1)); /// assert_eq!(width!(new_area), 1); -/// # } /// ``` #[macro_export] macro_rules! width { @@ -106,12 +94,8 @@ macro_rules! width { /// /// Example: /// ``` -/// # #[macro_use] extern crate ui; fn main() { -/// use ui::*; -/// /// let new_area = ((0, 0), (1, 1)); /// assert_eq!(upper_left!(new_area), (0, 0)); -/// # } /// ``` #[macro_export] macro_rules! upper_left { @@ -124,12 +108,8 @@ macro_rules! upper_left { /// /// Example: /// ``` -/// # #[macro_use] extern crate ui; fn main() { -/// use ui::*; -/// /// let new_area = ((0, 0), (1, 1)); /// assert_eq!(bottom_right!(new_area), (1, 1)); -/// # } /// ``` #[macro_export] macro_rules! bottom_right { @@ -142,15 +122,12 @@ macro_rules! bottom_right { /// /// Example: /// ``` -/// # #[macro_use] extern crate ui; fn main() { -/// use ui::*; -/// /// let valid_area = ((0, 0), (1, 1)); /// assert!(is_valid_area!(valid_area)); /// /// let invalid_area = ((2, 2), (1, 1)); /// assert!(!is_valid_area!(invalid_area)); -/// # } +/// ``` /// #[macro_export] macro_rules! is_valid_area {