Skip to content

fix(core): keep control characters out of multi-line input - #638

Merged
43081j merged 3 commits into
bombshell-dev:mainfrom
kuldeepsinh19:fix/multiline-control-characters
Nov 11, 2026
Merged

43081j merged 3 commits into
bombshell-dev:mainfrom
kuldeepsinh19:fix/multiline-control-characters

Conversation

@kuldeepsinh19

Copy link
Copy Markdown
Contributor

What does this PR do?

MultiLinePrompt inserts every keypress that carries a character. For named keys Node passes the raw sequence as that character, so Backspace at the start of the input inserts \x7f, and Ctrl combinations such as Ctrl+A insert \x01–\x1a. Terminals don't draw them, but they are returned in the value. #637 has the repro.

This PR only inserts characters that are text. Tab and newline behave as before, and no snapshots change.

  • The two regression tests fail on main (50c8ea0) and pass with the fix. The third test pins tab and newline, so the check can't quietly grow too broad.
  • Feeding the raw bytes \x7f \r \r to multiline({ defaultValue: 'none' }) returns a lone \x7f on 1.9.0 and "none" with this branch.
  • Node 24.22.1, pnpm 10.33.0: pnpm test (804 passed), pnpm types, pnpm deps and pnpm format pass.

Closes #637

Type of change

  • Bug fix
  • Feature
  • Refactor (no behavior change)
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • I have added a changeset

AI-generated code disclosure

  • This PR includes AI-generated code

The key handler inserted every keypress that carries a character. Named
keys are reported with their raw sequence, so backspace at the start of
the input inserted DEL and ctrl+key combinations inserted their control
character. Terminals do not draw them, but they were returned in the
value.
Tab and newline are control characters as well, but they are whitespace
a multi-line value can contain, so they have to keep being inserted.
@changeset-bot

changeset-bot Bot commented Nov 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 80ee1d0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@clack/core Patch
@clack/prompts Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dreyfus92 dreyfus92 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks, this looks right to me. i ran every control byte through real readline on main and on this branch, backspace at the start and ctrl combos are gone and tab and newline still work, and defaultValue kicks in again after a lone backspace.

i would love @43081j's second opinion before we merge.

@43081j

43081j commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

seems fine to me 👍

@pkg-pr-new

pkg-pr-new Bot commented Nov 11, 2026

Copy link
Copy Markdown

commit: 80ee1d0

@43081j
43081j merged commit 5f27460 into bombshell-dev:main Nov 11, 2026
10 of 11 checks passed
@bombshell-bot bombshell-bot Bot mentioned this pull request Nov 11, 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.

[Bug] multiline inserts control characters (Backspace at the start, Ctrl+key)

3 participants