diff options
| author | lukeflo | 2025-06-01 14:54:38 +0200 |
|---|---|---|
| committer | lukeflo | 2025-06-01 14:54:38 +0200 |
| commit | d64596242ab185fffebc773ad2dcb5f1be2fccc2 (patch) | |
| tree | 63c63e0d012b07ce66153ffba9dc7b13ebee0124 /src/tui/ui.rs | |
| parent | 62580d8cc537808c34b0d9a0fe5554b4806a7aa6 (diff) | |
| download | bibiman-d64596242ab185fffebc773ad2dcb5f1be2fccc2.tar.gz bibiman-d64596242ab185fffebc773ad2dcb5f1be2fccc2.zip | |
some fixes and test for `file_prefix` with new bool
Diffstat (limited to 'src/tui/ui.rs')
| -rw-r--r-- | src/tui/ui.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/tui/ui.rs b/src/tui/ui.rs index a998bc7..2126135 100644 --- a/src/tui/ui.rs +++ b/src/tui/ui.rs @@ -320,16 +320,24 @@ pub fn render_popup(app: &mut App, cfg: &BibiConfig, frame: &mut Frame) { // To find the longest line, we need to collect the chars of every item // and add. - let list_widths: Vec<u16> = app + let list_widths = app .bibiman .popup_area .popup_list .iter() - .map(|(m, o)| m.chars().count() as u16 + o.chars().count() as u16) - .collect(); + .max_by(|(mes, obj), (m, o)| { + let x = mes.chars().count() + obj.chars().count(); + let y = m.chars().count() + o.chars().count(); + x.cmp(&y) + }) + .unwrap(); + // .map(|(m, o)| m.chars().count() as u16 + o.chars().count() as u16) + // .collect(); // Now take the max number for the width of the popup - let max_item = list_widths.iter().max().unwrap().to_owned(); + // let max_item = list_widths.iter().max().unwrap().to_owned(); + let max_item = + list_widths.0.chars().count() as u16 + list_widths.1.chars().count() as u16; // Check if the popup would exceed the terminal frame width let popup_width = if max_item + 2 > frame.area().width - 2 { |
