forked from jroimartin/gocui
-
Notifications
You must be signed in to change notification settings - Fork 32
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 handling of \n
wrt inserting null cells
#68
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The test shows a bug with the handling of \n (but not with \r, it works fine there): if there's exactly one existing character in the current line after the write position, we overwrite it with a null character. We'll fix this in the next commit.
This fixes the bug described in the previous commit. This is the only behavior change in this branch, the rest of the commits are refactorings to simplify the code.
This has become possible with the previous commit, which made the code identical between \r and \n.
The readCell function was introduced in e659668 only for this purpose. We don't need it because: - the extra check for c.chr == 0 is not needed; if there is already a null cell at the line end, we needn't write it again. There is no difference between a null cell and a printable cell in this regard - the only check that's left is for the coordinates; we know that y is valid, and x is not less than 0, so the only check we need is for x against the length of the line.
This was referenced Jan 5, 2025
jesseduffield
approved these changes
Jan 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I believe we do overwrite existing text when re-rendering the main view after refreshing so I think this is a practical change, not just theoretical.
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.
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes a theoretical problem with overwriting existing lines where a line is exactly one character longer than what's being written; in this case we overwrite the existing character with a null character.
This is only a theoretical problem because to my knowledge we don't overwrite existing text anywhere, at least not in lazygit. The motivation of this PR was not so much to fix the bug, but to simplify the code; this makes it easier to put this PR on top of it.