Skip to content

Map mouse rows from the buffer line under the pointer - #766

Merged
dakra merged 1 commit into
mainfrom
fix/mouse-row-from-buffer
Oct 26, 2026
Merged

dakra merged 1 commit into
mainfrom
fix/mouse-row-from-buffer

Conversation

@dakra

@dakra dakra commented Oct 26, 2026

Copy link
Copy Markdown
Owner

ghostel--posn-cell computed the mouse row from the pixel Y. That assumed the window's top line is viewport row 0, or a partial scrollback line whenever there is a vscroll, and that every row is default-line-height tall. When either assumption breaks, events sent to mouse-tracking programs land one or more rows too high. Two cases that break it:

  • An enlarged minibuffer defers the terminal resize, so the window starts below viewport row 0.
  • A row is taller than the default.

The row is now the viewport row of the position's buffer line, via ghostel--viewport-row-at. Scrollback positions clamp to row 0. Positions without a buffer line (mode line, header line, frame) keep the pixel estimate. The column calculation is unchanged.

Checked live in elate, with clicks and drags compared against the old code:

  • With taller rows (ghostel-glyph-scale-floor 1.0), the old code was off by up to 4 rows; the new code was exact.
  • With a multi-line minibuffer open on the main screen, the old code was off by 1 to 2 rows; the new code was exact.
  • With uniform rows and ghostel-window-padding-balance set to center, both were correct.

Closes #765.

ghostel--posn-cell derived the row from the pixel Y, assuming the
window's top line is viewport row 0, or a partial scrollback line when
there is a vscroll, and that every row is default-line-height tall.
When that does not hold, e.g. while an enlarged minibuffer defers the
terminal resize and the window starts below viewport row 0, or a row
is taller than the default, mouse events sent to a mouse-tracking
program landed one or more rows too high.  Take the row from the
viewport row of the position's buffer line instead, falling back to
the pixel estimate only where a position has no buffer line (mode
line, header line, frame).

Closes #765.
@dakra
dakra force-pushed the fix/mouse-row-from-buffer branch from f699483 to 42de3eb Compare October 26, 2026 18:02
@dakra
dakra merged commit 42de3eb into main Oct 26, 2026
27 checks passed
@dakra
dakra deleted the fix/mouse-row-from-buffer branch October 26, 2026 18:02

This branch was previously deployed

1 inactive deployment
github-pages — 42de3eb3 Deployed Oct 26, 2026 by dakra via deploy #234
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.

in claude inside ghostel, selection with mouse results in previous line selected instead of the line I point the mouse to.

1 participant