Skip to content

Conversation

@stefanhaller
Copy link
Collaborator

…ruction"

This reverts commit 43d5fee.

The original commit message said:

    There is no need to overwrite things with spaces; since tcell clears the
    whole surface before drawing, it is enough to just truncate the line at the
    current write position.

As it turns out, this is only true if the background color is none; for the case
where where there's a background color set, we do need to draw spaces until the
end of the line. This happens, for example, when using the delta pager in
lazygit: the green and red bars for added and deleted lines didn't extend to the
right edge of the view.

The reason why I made the original commit in the first place is because the
previous implementation had two bugs, and simplifying things the way I did in
43d5fee made it unnecessary to fix these. Now that we are reverting the
simplification, we do need to fix those bugs, which I will do in the next three
commits.
We still need to truncate the line after executing the eraseInLineFromCursor
instruction, to remove left-over content from a previous rendering; just not at
the current write position, but after the spaces that were inserted.

Without this fix you would sometimes see left-over junk when scrolling
left/right using the H/L keys in the commits panel.
This code assumed that the length of the current line is the same as the current
x write position, which isn't necessarily true if we are overwriting existing
lines.

This hasn't been a problem before
jesseduffield/lazygit#3687 because we would only use the
erase-to-eol feature in cases where the length of the lines either didn't
change, or where we called v.clear before. As of that PR though, we can run into
it in lazygit for example when pressing "+" to expand the commits view and then
going back.
Truncating to the end of the line would draw one space too few. Again, this
wasn't a problem before jesseduffield/lazygit#3687, but
when redrawing the commits panel it could be observed when using the H/L keys.
@stefanhaller stefanhaller merged commit ea75eca into master Aug 17, 2024
@stefanhaller stefanhaller deleted the fix-delta-line-coloring branch August 17, 2024 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants