-
Notifications
You must be signed in to change notification settings - Fork 61
feature: avoid inline text for checkboxes to maintain cursor position #378
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
Labels
enhancement
New feature or request
Comments
MeanderingProgrammer
added a commit
that referenced
this issue
Mar 24, 2025
## Details Request: #378 Previously checkboxes were rendered by concealing the underlying text and inlining the icon as virtual text. This works but would mess with the cursor positions while scrolling due to how neovim handles showing and hiding inline virtual text. To avoid this we now use information about the amount of space available to us, i.e. the width of the text in square brackets compared to the width of the icon we are rendering, to add more clever marks. Only when the icon is larger than the space available do we do the same thing as before and fully conceal + inline. Otherwise we use overlay virtual text to show the icon and conceal any underlying text that extends under the icon (if any). When doing this we also take into account the new `checkbox.right_pad` option (default value 1), and similarly attempt to use the space available for the padding. If the padding extends outside the available space then the remaining amount is added as inline virtual text, requires neovim >= `0.10.0` to work. The default value of 1 is chosen so that the rendered text looks identical in most cases to before, since we now treat the space after the checkbox as space available to us. ### Related Impacts To maintain parity with how checked and unchecked checkboxes are handled by `markdown`, we now require that there is a space following custom states. This allows us to better determine exactly how much space we have to work with. The `checkbox.position` configuration option was removed. We now infer how to display checkboxes best based on the space available to us and the icon we are about to show. Any potential differences in how things are displayed, can likely be changed back by using the new `checkbox.right_pad` option. Most users should not see any differences. Any users of `checkbox.position` should simply remove it from their configuration, keeping it is fine, it just doesn't do anything. Custom checkbox states will now work for versions of neovim older than `0.10.0`, but since the plugin as a whole still requires `0.9.0` at a minimum this only adds a couple supported versions for that specific feature, and there are some limitations to its usage.
Implemented better checkbox rendering here: f9badfb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Neovim version (nvim -v)
0.10.4
Neovim distribution
N/A
Operating system
Any
Terminal emulator / GUI
Any
Describe the bug
The cursor does not keep the correct position when moving down a list of checkboxes:
[ ]
j
the cursor is at
[
instead of inside[ ]
Expected behavior
To keep the correct cursor position when moving down the list of checkboxes
Healthcheck output
Plugin configuration
Plugin error log
Confirmations
Additional information
No response
The text was updated successfully, but these errors were encountered: