Skip to content

Commit

Permalink
Fix row height calculation to use usable column widths
Browse files Browse the repository at this point in the history
  • Loading branch information
YS-L committed Aug 27, 2023
1 parent 6b11c0d commit c8ec7a7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,14 @@ impl<'a> CsvTable<'a> {
for (j, content) in row.fields.iter().enumerate() {
let mut num_lines = 0;
for parts in content.split('\n') {
let parts_length = parts.chars().count();
num_lines += max(
1,
match column_widths.get(j) {
Some(w) => (parts.len() as f32 / *w as f32).ceil() as u16,
Some(w) => {
let usable_width = (*w).saturating_sub(NUM_SPACES_BETWEEN_COLUMNS);
(parts_length as f32 / usable_width as f32).ceil() as u16
}
None => 1,
},
);
Expand Down

0 comments on commit c8ec7a7

Please sign in to comment.