Skip to content

fix(input): send no motion report for a drag that stays in its cell - #876

Merged
vyncint merged 2 commits into
vyncint:mainfrom
alvaroalonsoparrondo-a11y:fix/zero-length-drag
Nov 27, 2026
Merged

vyncint merged 2 commits into
vyncint:mainfrom
alvaroalonsoparrondo-a11y:fix/zero-length-drag

Conversation

@alvaroalonsoparrondo-a11y

Copy link
Copy Markdown
Contributor

Fixes #834

cells_between returned the destination when a drag had no length, so under ?1002 / ?1003 a drag whose two ends were the same cell sent a press, a motion report and a release. xterm sends a motion report only when the pointer enters another cell (button.c, EditorButton), and the press has already recorded the cell, so the terminal delivers a click.

  • crates/termlens/src/terminal.rs: cells_between returns no cells when the ends are the same cell, and its comment says why. drag's rustdoc says a drag that stays in its cell is a press and a release.
  • Tests:
    • the unit test that pinned the old behaviour, a_drag_that_goes_nowhere_still_reports_one_motion, becomes a_drag_that_stays_in_its_cell_crosses_none, which also checks that a one-cell drag still reports its one cell.
    • the issue's case end to end in tests/input.rs, a_drag_that_stays_in_its_cell_reports_no_motion, next to a_drag_reports_one_motion_per_cell_crossed and with the same fixture: the wire has [<0;7;2M and [<0;7;2m and no [<32;. It fails with the old cells_between. Ignored on Windows like its neighbours (Unix only: what Windows support would actually take #149).
    • The other drag tests in tests/input.rs still pass (37 passed), so a drag of one cell or more still sends one motion report per cell crossed.
  • CHANGELOG: entry under Unreleased → Fixed.

Checked on macOS: cargo fmt --all --check, cargo clippy -p termlens --all-targets --all-features -- -D warnings, cargo test -p termlens --test input, the cells_between unit tests, check-dco.sh and check-no-ai-attribution.sh.

Álvaro Alonso
242080768+alvaroalonsoparrondo-a11y@users.noreply.github.com

Fixes vyncint#834

Signed-off-by: Álvaro Alonso <242080768+alvaroalonsoparrondo-a11y@users.noreply.github.com>
vyncint
vyncint previously approved these changes Nov 27, 2026

@vyncint vyncint left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Reviewed against the issue; CI is green. Thank you.

Signed-off-by: Vyncint Ng <115854244+vyncint@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
@vyncint
vyncint merged commit 53a4e8e into vyncint:main Nov 27, 2026
17 checks passed
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.

A drag that starts and ends in one cell sends a motion report; xterm reports motion only on a cell change

2 participants