fix(tui): reserve 1 column for the cursor in word wrap width #934
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 PR fixes an issue with the cursor placement when the text fills the entire width. The cursor appears to be on the last character, but it's actually one character further. The solution is to reserve a column for the cursor and wrap the text one character early. When padding is set, allow the cursor to be displayed in the padding, which also makes the rendering logic simpler.
Here's the demonstration of the issue and the solution:
Screen.Recording.2026-01-24.at.17.12.44.mov
I also explored another option, which was to add a new line and put the cursor there, but it was a bit janky. Pressing Up in that state didn't move the cursor up to the second-to-last line, and the new line would disappear if you moved the cursor left. So, I didn't pursue it. You could probably make it work with enough determination, but I thought that was a bit too much.