fix: adjust calculation for number of lines in a notification message (#828)

Co-authored-by: sxyazi <sxyazi@gmail.com>
This commit is contained in:
Rolv Apneseth 2024-03-20 05:14:48 +00:00 committed by GitHub
parent 955e8f59a9
commit 9918ceb7f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -36,7 +36,11 @@ impl Message {
return 0; // In case we can't get the width of the terminal
}
let lines = (self.content.width() as f64 / width as f64).ceil();
lines as usize + NOTIFY_BORDER as usize
let mut lines = 0;
for line in self.content.lines() {
lines += (line.width() + 1).div_ceil(width as usize)
}
lines + NOTIFY_BORDER as usize
}
}