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

editor: Fix inline Git blame not visible on long lines due to overflow #23374

Merged
merged 4 commits into from
Jan 28, 2025

Conversation

0xtimsb
Copy link
Member

@0xtimsb 0xtimsb commented Jan 20, 2025

Closes #18702

This is take 2 of my previous PR, which was closed due to inactivity and merge conflicts.

Cause:

The editor's horizontal scroll width only considers the longest line in the buffer, using layout_line for longest_row. The inline blame width isn’t included in it because it is just a decoration on top of the line (think of like CSS absolute) and not part of its actual content. This causes blame to overflow.

Solution:

Along with longest_row width we also add that line's inline blame width for scroll width calculation. We also have to add some padding that is between inline blame and line's content.

Alternate Solution:

In my previous PR, instead of adding the inline blame width of the longest line for scroll width calculation, I used the inline blame of the current line the cursor is on (since we only see the blame for the current line). I added that to the current line's width, giving us the full width of that row. Then, we compare that row's width with the longest row width and use the max of the two for the scroll width calculation.

While this solution seems clever, it's overly complicated and could cause issues, like the scroll width changing every time you move the cursor up or down. I don't think we should go with this, but I'm open to suggestions.

Preview:

Before:

before.mp4

After:

after.mp4

Release Notes:

  • Fixed inline Git blame not visible on long lines due to overflow.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 20, 2025
@@ -6324,7 +6326,6 @@ impl Element for EditorElement {
cx,
);

let mut max_visible_line_width = Pixels::ZERO;
Copy link
Member Author

Choose a reason for hiding this comment

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

This variable was not being used anywhere, so removed it.

@0xtimsb 0xtimsb force-pushed the inline-git-overflow branch from b7f731f to ad69ed0 Compare January 26, 2025 13:01
Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

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

Thanks!

@SomeoneToIgnore SomeoneToIgnore self-assigned this Jan 28, 2025
@SomeoneToIgnore SomeoneToIgnore merged commit 34d0b57 into zed-industries:main Jan 28, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Git blame not visible if line too long compared to window
2 participants