mirror of
https://github.com/youwen5/iamb.git
synced 2025-06-19 21:29:52 -07:00
Fix truncation/padding for non-ASCII sender names (#182)
This commit is contained in:
parent
5be886301b
commit
1cb280df8b
2 changed files with 16 additions and 16 deletions
|
@ -58,7 +58,7 @@ use crate::{
|
|||
base::{IambResult, RoomInfo},
|
||||
config::ApplicationSettings,
|
||||
message::html::{parse_matrix_html, StyleTree},
|
||||
util::{space_span, wrapped_text},
|
||||
util::{space, space_span, take_width, wrapped_text},
|
||||
};
|
||||
|
||||
mod html;
|
||||
|
@ -909,13 +909,13 @@ impl Message {
|
|||
}
|
||||
|
||||
let Span { content, style } = self.sender_span(info, settings);
|
||||
let stop = content.len().min(28);
|
||||
let s = &content[..stop];
|
||||
let ((truncated, width), _) = take_width(content, 28);
|
||||
let padding = 28 - width;
|
||||
|
||||
let sender = if align_right {
|
||||
format!("{: >width$} ", s, width = 28)
|
||||
space(padding) + &truncated + " "
|
||||
} else {
|
||||
format!("{: <width$} ", s, width = 28)
|
||||
truncated.into_owned() + &space(padding) + " "
|
||||
};
|
||||
|
||||
Span::styled(sender, style).into()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue