Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix image preview placement when messages are preceded by a date in the timeline #257

Merged
merged 1 commit into from
Apr 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/message/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,8 @@ impl Message {
let proto = proto.map(|p| {
let y_off = text.lines.len() as u16;
let x_off = fmt.cols.user_gutter_width(settings);
// Adjust y_off by 1 if a date was printed before the message to account for the extra line.
let y_off = if fmt.date.is_some() { y_off + 1 } else { y_off };
Copy link
Owner

@ulyssa ulyssa Apr 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! This isn't quite right though, since if there's a reply then text.lines will already include the date, and we'll double count it here. The date printing code should probably be moved out of MessageFormatter::push_spans and into its own MessageFormatter::push_date method that gets called before pushing the reply text instead.

EDIT: Nevermind, that's wrong since the self.date.take() will make this None. This looks good to me!

(p, x_off, y_off)
});

Expand Down
Loading