macOS delay on incomplete escape sequences to avoid spurious escape keypress detection #132 #176
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This proposed solution to the macOS partial escape sequence problem can be contrasted against #158 (which is similar to another proposal from the comment thread on #132). Compared with that solution, this one is more complicated but will handle the case where an escape sequence is interrupted such that ONLY the escape character comes through ahead of the rest of the sequence. It's not proven whether that's possible since AFAICT we don't understand the mechanism by which the escape sequences are being split up in macOS, but then the whole problem here is nondeterminism.
Also this solution relies on an arbitrary delay which works according to my testing but is not verifiably "correct". This causes an short delay in processing of plain Escape keypresses. The delay is supposed to be long enough to let long escape sequences finish, but short enough not to be noticeable by the user. I have it set to 50 ms in my commit but this is obviously debatable and subject to observed behavior.
Whether this solution is better than the simpler one (if the simpler one were modified to be macOS only) I leave up to @nsf :)
Outline of this solution: