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

Conversation

reynoldsme
Copy link
Contributor

Currently image previews are printed one line too high if the message had a date inserted into it indicating a change of date between the current and preceding message. With this PR we conditionally check if a date was inserted and adjust the y offset used to place the rendered the image.

Tested in: XTerm(374), wezterm 20240203-110809-5046fc22, and konsole 24.02.1.

Before change:
before change

After change:
after

@ulyssa ulyssa added bug Something isn't working ui Issues related to rendering, widgets, or general terminal-related issues labels Apr 13, 2024
@@ -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!

@ulyssa ulyssa merged commit 91ca50a into ulyssa:main Apr 13, 2024
3 checks passed
@ulyssa
Copy link
Owner

ulyssa commented Apr 13, 2024

Merged! Thank you for fixing this!

@ulyssa ulyssa added this to the v0.0.10 milestone Apr 24, 2024
@ulyssa ulyssa mentioned this pull request Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ui Issues related to rendering, widgets, or general terminal-related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants