Skip to content
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

Cursor can leave visible area when line numbers enabled #77

Closed
achristmascarl opened this issue Aug 1, 2024 · 2 comments
Closed

Cursor can leave visible area when line numbers enabled #77

achristmascarl opened this issue Aug 1, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@achristmascarl
Copy link
Contributor

Repro

  1. create textarea with line numbers enabled (or run the editor example)
  2. type in the textarea until it reaches the right-most border of the textarea
  3. keep typing and observe that chars are inserted but cursor is no longer visible
  4. move cursor to the left 3-5 times and observe that the cursor is visible again
  5. create textarea without line numbers (or run vim example)and observe that 2-5 do not happen

Expected Behavior

The cursor always stops before leaving the visible area or causes the visible area to scroll to keep the cursor visible.

Actual Behavior

The number of cells the cursor can move beyond the visible area corresponds to how much width is taken up by the line numbers (e.g. for single digit line numbers, the width of the line numbers section is 3, so the cursor can move 3 past the visible area; with double digit line numbers, the width is 4, so the cursor can move 4 beyond), so I'm guessing the calculations for the boundaries/scrolling just aren't taking the line numbers section's width into account.

Env

  • kitty on macOS
  • rust 1.79.0
  • tui-textarea 0.5.2
  • ratatui 0.27.0
@rhysd rhysd added the bug Something isn't working label Aug 2, 2024
@rhysd
Copy link
Owner

rhysd commented Aug 2, 2024

Thanks for reporting this. I confirmed this is a bug on calculating the cursor position.

@rhysd rhysd closed this as completed in ef28d09 Aug 2, 2024
@rhysd
Copy link
Owner

rhysd commented Aug 3, 2024

The fix was included in v0.5.3 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants