add stable keyboard scrolling to vim floating preview popups#5114
add stable keyboard scrolling to vim floating preview popups#5114coriocactus wants to merge 5 commits intodense-analysis:masterfrom
Conversation
80f3c87 to
dd89b90
Compare
vim popupwin floating previews had no reliable keyboard scrolling, so long hover and detail content was awkward to read without the mouse add a popup filter for <C-n>/<C-p>, <C-d>/<C-u>, mouse wheel scrolling, and <Esc>, clamp scrolling at the popup bounds, and keep popup size stable while visible by locking width to the widest popup content line
dd89b90 to
3d67758
Compare
row counting assumed wrap was always on, causing long lines to count as multiple rows even when wrap is disabled via popup opts, which stops scrolling too early
resize: v:true in the default popup opts contradicts the size locking that pins min/max width and height to exact values, disable resize while ALE manages size and restore it on reset
There was a problem hiding this comment.
Pull request overview
Adds keyboard (and mouse wheel) scrolling support for Vim popupwin-based floating preview windows in ALE, plus sizing stabilization to prevent resize jitter while scrolling. NeoVim floating previews are unchanged.
Changes:
- Introduces a Vim popup
filter(normal-mode filtermode) to handle<C-n>/<C-p>,<C-d>/<C-u>, mouse wheel, and<Esc>for floating preview popups. - Adds “managed” width/height locking for Vim popups when users haven’t provided explicit size limits.
- Adds a new Vader test suite covering scrolling behavior, boundary clamping, closing on escape, passthrough keys, and size locking; updates docs accordingly.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
autoload/ale/floating_preview.vim |
Implements popup filter, scroll/clamp logic, and managed size locking/reset for Vim popup previews. |
doc/ale.txt |
Documents the new scrolling keys and sizing behavior for Vim popup previews and how to override the filter. |
test/test_floating_preview_popupwin.vader |
Adds coverage for popup filter behavior, scroll boundaries, escape close, and size stability during scrolling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| keyboard and dismissed with |<Esc>|. The following keys are supported: | ||
|
|
||
| |<C-n>| - Scroll down one line | ||
| |<C-p>| - Scroll up one line | ||
| |<C-d>| - Scroll down half a page | ||
| |<C-u>| - Scroll up half a page | ||
| |<Esc>| - Close the popup |
There was a problem hiding this comment.
The new key references are formatted as Vim help links (e.g. |<C-n>|, |<Esc>|), but these aren’t standard help tags and will render as broken links. In this help file, key help tags are typically referenced as |CTRL-N|, |CTRL-P|, etc. Consider switching to the existing tag style (or removing |...| markup and just using <C-n>/<Esc> as plain text).
| keyboard and dismissed with |<Esc>|. The following keys are supported: | |
| |<C-n>| - Scroll down one line | |
| |<C-p>| - Scroll up one line | |
| |<C-d>| - Scroll down half a page | |
| |<C-u>| - Scroll up half a page | |
| |<Esc>| - Close the popup | |
| keyboard and dismissed with <Esc>. The following keys are supported: | |
| <C-n> - Scroll down one line | |
| <C-p> - Scroll up one line | |
| <C-d> - Scroll down half a page | |
| <C-u> - Scroll up half a page | |
| <Esc> - Close the popup |
vim floating preview windows for hover and detail output had no keyboard scrolling, so long content required the mouse to read
this adds a popup filter for Vim popupwin previews that handles / for line scrolling, / for half-page scrolling, mouse wheel events, and to dismiss; unhandled keys pass through normally and moved: 'any' still closes the popup on cursor movement; to prevent resize jitter while scrolling, ALE locks popup width to the maximum content display width and height to the rendered height when users have not set size limits themselves, and disables resize while those managed dimensions are active; scroll clamping at both boundaries prevents the viewport from moving into blank space, and the bottom boundary accounts for line wrapping as well as wrap: 0; users can override the filter or supply explicit sizing via g:ale_floating_preview_popup_opts, and neovim floating windows are unchanged
the filter runs in filtermode: 'n' so it does not interfere with insert-mode completion keys; mapping is left at the default so user normal-mode mappings are respected, which means custom mappings on etc will take precedence over popup scrolling; the size-locking cleanup uses unlet! defensively so future refactors cannot hit a missing-key error on managed_size