fix(website): route trailing bytes to a program launched mid-chunk in tutorial shell#245
Open
dormouse-bot wants to merge 1 commit into
Open
fix(website): route trailing bytes to a program launched mid-chunk in tutorial shell#245dormouse-bot wants to merge 1 commit into
dormouse-bot wants to merge 1 commit into
Conversation
… tutorial shell TutorialShell.handleInput only checked activeProgram at the top of the method, so when a single input chunk both launched an interactive program (via a trailing \r) and carried the program's first keystroke — as a paste of "cmd\rinput" would — the leftover bytes were parsed as shell line-editor input instead of being forwarded to the just-started program. Forward any bytes remaining after a program launch to that program and stop parsing the chunk. Adds a regression test that fails without the fix.
Deploying mouseterm with
|
| Latest commit: |
3c0f562
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5ada2456.mouseterm.pages.dev |
| Branch Preview URL: | https://fix-tutorial-shell-midchunk.mouseterm.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Surfaced by the nightly code-quality survey.
TutorialShell.handleInputchecksthis.activeProgramonly once, at the top of the method. Inside the per-character loop, when a\r/\ntriggersprocessCommandand that launches an interactive program, the loop keeps going and treats the rest of the chunk as shell line-editor input.When input arrives one keystroke per chunk (normal typing) this never bites, because the
\ris the last byte. But a single chunk that carries both the command and its first keystroke — e.g. a paste ofascii-splash\rq— mis-routes theqinto the shell'slineBufferinstead of forwarding it to the just-started program. The existing tests split these across twohandleInputcalls, so the case was uncovered.The fix forwards any bytes remaining after a mid-chunk program launch to that program and stops parsing the chunk.
The added regression test (
forwards trailing bytes to a program launched within the same chunk) fails before the fix (program.handleInputcalled 0 times) and passes after.