Skip to content

Conversation

@stefanhaller
Copy link
Collaborator

Line-wrapping a commit trailer that contains a very long email address results
in a broken trailer (trailers do support being split into several lines, but
this requires continuation lines to start with a space, like in RFC-822 message
headers). To avoid this, simply never wrap commit trailers.

It's a bit questionable that we hard-code this behavior in TextArea, which is
meant to be a general-purpose widget; but we know we only use it in lazygit's
commit message panel, so don't bother making this configurable for now.

Fixes jesseduffield/lazygit#5216.

stefanhaller added a commit to jesseduffield/lazygit that referenced this pull request Jan 24, 2026
This brings in jesseduffield/gocui#97 ("Exclude commit
trailers from line wrapping").
@stefanhaller stefanhaller force-pushed the dont-wrap-commit-trailers branch from c100b6d to 4d58a88 Compare January 24, 2026 15:17
Copy link

@sogladev sogladev left a comment

Choose a reason for hiding this comment

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

I forgot Strings.builder was a thing when writing. This is much nicer.

I tested the changes in jesseduffield/lazygit#5230, and it works as expected

Closing my PR (jesseduffield/lazygit#5217) as it's no longer needed

return
}

if len(chr) != 1 {

Choose a reason for hiding this comment

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

This is minor, but footnotes are also all ASCII, and the same optimization can be used to skip some regex checks

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Interesting, but that would actually make it worse. I added a bit of benchmark data (587285e) for this, and adding the check to the footnote matcher increases the benchmark time by a couple of microseconds.

I need to keep the check for the trailer matcher though, because it's needed for correctness, since I access the bytes of the string a few lines below, so I first need to make sure it's really one byte.

@stefanhaller stefanhaller force-pushed the dont-wrap-commit-trailers branch from 4d58a88 to 30a4af5 Compare January 25, 2026 10:12
@stefanhaller
Copy link
Collaborator Author

@sogladev Thanks for the review! Merging.

This is calling contentToCells for every key press. As we are going to make
changes to that function in this branch, we want to make sure that we don't
cause a terrible performance regression with our changes.

On my machine, one benchmark iteration takes 150μs, which is already a lot less
than I had expected.
Line-wrapping a commit trailer that contains a very long email address results
in a broken trailer (trailers do support being split into several lines, but
this requires continuation lines to start with a space, like in RFC-822 message
headers). To avoid this, simply never wrap commit trailers.

It's a bit questionable that we hard-code this behavior in TextArea, which is
meant to be a general-purpose widget; but we know we only use it in lazygit's
commit message panel, so don't bother making this configurable for now.

Benchmark time increases from 150μs to 165μs on my machine, which is still more
than acceptable.
@stefanhaller stefanhaller force-pushed the dont-wrap-commit-trailers branch from 30a4af5 to 8029be2 Compare January 25, 2026 10:19
@stefanhaller stefanhaller merged commit dd3e333 into master Jan 25, 2026
1 check passed
@stefanhaller stefanhaller deleted the dont-wrap-commit-trailers branch January 25, 2026 10:20
stefanhaller added a commit to jesseduffield/lazygit that referenced this pull request Jan 25, 2026
This brings in jesseduffield/gocui#97 ("Exclude commit
trailers from line wrapping").
stefanhaller added a commit to jesseduffield/lazygit that referenced this pull request Jan 25, 2026
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.

Auto-wrap breaks long co author string

2 participants