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

Fix incorrect auto-scroll/follow behavior in TUI #306

Merged
merged 3 commits into from
Jul 24, 2024

Conversation

evanrelf
Copy link
Member

@evanrelf evanrelf commented Jul 23, 2024

The code to follow logs had a bug where it'd increment the scroll offset regardless of how much of the screen was filled, so on startup it would start "following", pushing the logs up off the top.

This PR adds a second check to wait until the logs have filled the screen before auto-incrementing the scroll offset to follow.


I also tweaked the formatting of the key mapping matches to be more readable (IMO) and introduced a rudimentary debug status bar (hidden by default) which was essential for understanding this bug and fixing it.

I've found keeping debug info like this readily available to be a huge boon when working on my text editor project. I recommend keeping this in the code, at least while the TUI is in an experimental stage. But I'm also happy to remove if you'd rather not include that change.


Commits are atomic; I recommend reviewing them individually.

evanrelf added 3 commits July 22, 2024 16:46
It was super spread out, and modifiers and codes weren't paired
visually.
Separate keys for enabling and disabling, because holding the key down
for too long counts as multiple inputs, and causes the debug info to
flicker.

Fix is straightforward - either ignore `KeyEventKind::Repeat`, or record
a past `KeyEventKind::Press` and wait for a `KeyEventKind::Release`
before toggling again - but that's too much work right now for this
hacky debug thing.
@evanrelf evanrelf requested a review from 9999years July 23, 2024 00:12
@github-actions github-actions bot added the patch Bug fixes or non-functional changes label Jul 23, 2024
@evanrelf evanrelf changed the title Fix weird initial scroll position in TUI Fix incorrect auto-scroll/follow behavior in TUI Jul 23, 2024
@evanrelf evanrelf merged commit d043bd4 into main Jul 24, 2024
40 checks passed
@evanrelf evanrelf deleted the evan/fix-weird-initial-scroll branch July 24, 2024 16:04
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Bug fixes or non-functional changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants