Skip to content

test/util/keys: wait for the editor to read input around escapes - #1450

Closed
mcepl wants to merge 1 commit into
martanne:masterfrom
openSUSE-Python:test-keys-escape-race
Closed

mcepl wants to merge 1 commit into
martanne:masterfrom
openSUSE-Python:test-keys-escape-race

Conversation

@mcepl

@mcepl mcepl commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

vis takes an escape followed by another key within its escape delay (50 ms) as an Alt modifier. keys only slept 100 ms after writing an escape, which is not enough on a loaded machine: vis reads all pending input at once and may still be processing the keys before the escape when the next key arrives. It then reads e.g. j as , and the test fails. This made the vim comparison tests fail at random on busy build machines, e.g. golf/4fbf8e303be58b0001000024/1 and operators/replace/replace.

When writing to a pipe, wait until the editor has read all input before writing an escape, so that the escape is read on its own, and again after it, before sleeping. The waits use FIONREAD and are bounded, so an editor that died cannot hang the test. Where FIONREAD does not report unread data, nothing changes.

With four busy loops pinned to the same CPU as vis, the golf test failed in 10 out of 10 runs before and passed in 20 out of 20 after.

vis takes an escape followed by another key within its escape
delay (50 ms) as an Alt modifier. keys only slept 100 ms after
writing an escape, which is not enough on a loaded machine: vis
reads all pending input at once and may still be processing the
keys before the escape when the next key arrives. It then reads
e.g. <Escape>j as <M-j>, and the test fails. This made the vim
comparison tests fail at random on busy build machines, e.g.
golf/4fbf8e303be58b0001000024/1 and operators/replace/replace.

When writing to a pipe, wait until the editor has read all input
before writing an escape, so that the escape is read on its own,
and again after it, before sleeping. The waits use FIONREAD and
are bounded, so an editor that died cannot hang the test. Where
FIONREAD does not report unread data, nothing changes.

With four busy loops pinned to the same CPU as vis, the golf test
failed in 10 out of 10 runs before and passed in 20 out of 20
after.

Signed-off-by: Matěj Cepl <mcepl@cepl.eu>
@openSUSE-Python openSUSE-Python closed this by deleting the head repository Nov 16, 2026
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