Skip to content

Conversation

@stefanhaller
Copy link
Collaborator

If writeString or writeRunes is called with text ending in a newline character (which is very common), we currently insert an extra blank line at the bottom of the view, which doesn't look right. Avoid adding this extra line unless more text is added with another writeString call.

Sits on top of #68.

Copy link
Owner

@jesseduffield jesseduffield left a comment

Choose a reason for hiding this comment

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

LGTM. Intuitively I feel that this is an unnecessary change and that it's good to know that there's a newline at the end of the file, but given I've got lazygit configured to allow scrolling past the end, I have no experience with this problem in the first place, so I'm happy to defer to your judgement.

Base automatically changed from fix-eol-handling to master January 6, 2025 07:57
@stefanhaller stefanhaller force-pushed the avoid-blank-line-at-end-of-view branch from c095b97 to 3fa31d2 Compare January 6, 2025 07:57
@stefanhaller
Copy link
Collaborator Author

LGTM. Intuitively I feel that this is an unnecessary change and that it's good to know that there's a newline at the end of the file,

I see this as similar to viewing a file in less. If you view a file that's longer than the height of the screen, and scroll all the way to the bottom, it doesn't show a blank line for the last line feed either. It does for any additional line feeds at the end though (if you have more than one \n at the end of the file), and I agree that this is important, but we do that here, too.

@stefanhaller stefanhaller merged commit 164661a into master Jan 6, 2025
1 check passed
@stefanhaller stefanhaller deleted the avoid-blank-line-at-end-of-view branch January 6, 2025 08:03
stefanhaller added a commit to jesseduffield/lazygit that referenced this pull request Jan 6, 2025
This updates gocui to include jesseduffield/gocui#68 and
jesseduffield/gocui#69, which changes views to not have
an extra blank line at the end when content ending in a newline character is
written to them. This makes text views more consistent with list views, which
don't have a blank line after the last list entry either.
@jesseduffield
Copy link
Owner

Makes sense

stefanhaller added a commit to jesseduffield/lazygit that referenced this pull request Jan 7, 2025
This updates gocui to include jesseduffield/gocui#68 and
jesseduffield/gocui#69, which changes views to not have
an extra blank line at the end when content ending in a newline character is
written to them. This makes text views more consistent with list views, which
don't have a blank line after the last list entry either.
stefanhaller added a commit to jesseduffield/lazygit that referenced this pull request Jan 7, 2025
- **PR Description**

This updates gocui to include
jesseduffield/gocui#68 and
jesseduffield/gocui#69, which changes views to
not have an extra blank line at the end when content ending in a newline
character is written to them. This makes text views more consistent with
list views, which don't have a blank line after the last list entry
either.
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.

3 participants