Skip to content

add stable keyboard scrolling to vim floating preview popups - #5114

Open
coriocactus wants to merge 1 commit into
dense-analysis:masterfrom
coriocactus:add-floating-preview-keyboard-scrolling
Open

coriocactus wants to merge 1 commit into
dense-analysis:masterfrom
coriocactus:add-floating-preview-keyboard-scrolling

Conversation

@coriocactus

@coriocactus coriocactus commented Apr 4, 2026 •

Copy link
Copy Markdown
Contributor

Vim floating previews (ALEHover, ALEDetail) have no keyboard scrolling, and moved: 'any' closes the popup on any cursor motion.

This adds a Normal-mode popup filter for Vim floating previews:

  • CTRL-E/CTRL-Y (line), CTRL-D/CTRL-U (half-page), and CTRL-F/CTRL-B (page) scroll the popup when its text overflows, and pass through when everything fits.
  • <Esc> closes the popup.
  • Setting filter in g:ale_floating_preview_popup_opts still overrides the default filter.

Notes:

  • Scrolling runs counted CTRL-D/CTRL-U via win_execute(), which stops cleanly at buffer bounds (including wrapped lines) without shrinking the popup, followed by redraw to prevent wrapped-line overscroll on Vim 8.2 when keys arrive faster than redraws.
  • Before Vim 9.2.0419, popup width is computed from visible lines only and resizes while scrolling. On older versions, minwidth is pinned to the widest line unless minwidth or maxwidth is set in g:ale_floating_preview_popup_opts.

@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
@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
@hsanson
hsanson requested a review from Copilot April 10, 2026 14:15
@hsanson
hsanson requested a review from w0rp April 10, 2026 14:20

Copilot AI left a comment

Copy link
Copy Markdown

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 thread doc/ale.txt Resolved
@w0rp

w0rp commented May 12, 2026

Copy link
Copy Markdown
Member

I'll paste this in every open PR: We finally managed to migrate CI checks for Windows from AppVeyor to GitHub Actions, and we've updated the minimum supported Vim version to 8.2. (Thought Vim 8.0 might happen to work for some.) In order to get checks to run again for a PR you'll need to rebase or merge.

@coriocactus
coriocactus force-pushed the add-floating-preview-keyboard-scrolling branch from e514c40 to 3ad02af Compare May 13, 2026 04:48
@coriocactus
coriocactus force-pushed the add-floating-preview-keyboard-scrolling branch 2 times, most recently from 39ff78d to df9465f Compare October 8, 2026 18:50
@rymdbar

rymdbar commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

How to try out this pull-request:

  1. Ensure vim, ale (doh!), cargo and rust-analyzer are installed.
  2. Configure .vimrc to contain let g:ale_floating_preview = 1 and let g:ale_linters.rust = [ 'rustc' ].
  3. Create a rust project.
mkdir pr5114
cd pr5114/
cargo init
  1. Update src/main.rs to contain:
fn main() {
    let x = 42;
    let y: String = x;
}
  1. Resize vim to be only 5-6 lines tall. Run :ALEDetail and observe the problem as described.

  2. Checkout pull-request branch.

  3. Observe how the issue is solved.

@rymdbar

rymdbar commented Nov 8, 2026

Copy link
Copy Markdown
Contributor
  1. Observe how the issue is solved.

Adding to this, I've also had a read-through of the actual diff and find it looking reasonable enough. My recommendation to @hsanson is to merge this.

@coriocactus
coriocactus force-pushed the add-floating-preview-keyboard-scrolling branch from df9465f to df8cd90 Compare November 14, 2026 13:47
@rymdbar

rymdbar commented Nov 15, 2026

Copy link
Copy Markdown
Contributor
  1. Observe how the issue is solved.

Adding to this, I've also had a read-through of the actual diff and find it looking reasonable enough. My recommendation to @hsanson is to merge this.

Yesterday's force-push was a clean rebase without new changes. Thus my recommendation for @hsanson remains to merge this.

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.

4 participants