Skip to content

add stable keyboard scrolling to vim floating preview popups#5114

Open
coriocactus wants to merge 5 commits intodense-analysis:masterfrom
coriocactus:add-floating-preview-keyboard-scrolling
Open

add stable keyboard scrolling to vim floating preview popups#5114
coriocactus wants to merge 5 commits intodense-analysis:masterfrom
coriocactus:add-floating-preview-keyboard-scrolling

Conversation

@coriocactus
Copy link
Copy Markdown
Contributor

@coriocactus coriocactus commented Apr 4, 2026

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

@coriocactus coriocactus force-pushed the add-floating-preview-keyboard-scrolling branch from 80f3c87 to dd89b90 Compare April 4, 2026 07:25
@coriocactus coriocactus marked this pull request as draft April 4, 2026 08:11
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
@coriocactus coriocactus force-pushed the add-floating-preview-keyboard-scrolling branch from dd89b90 to 3d67758 Compare April 4, 2026 08:36
@coriocactus coriocactus marked this pull request as ready for review April 4, 2026 08:41
@coriocactus coriocactus changed the title add keyboard scrolling and dismiss to floating preview popups add stable keyboard scrolling to vim floating preview popups Apr 4, 2026
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
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +839 to +845
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
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants