Skip to content

fix(ext/node): multiple readline improvements#32538

Merged
bartlomieju merged 1 commit intodenoland:mainfrom
bartlomieju:fix/readline-improvements
Mar 9, 2026
Merged

fix(ext/node): multiple readline improvements#32538
bartlomieju merged 1 commit intodenoland:mainfrom
bartlomieju:fix/readline-improvements

Conversation

@bartlomieju
Copy link
Copy Markdown
Member

Summary

Several fixes and feature additions to the Node.js readline polyfill:

  • Fix tab completion column formattingMath.max.apply(completionsWidth) was missing the array argument, causing all completions to display one-per-line instead of in columns
  • Fix historySize validation — now throws ERR_OUT_OF_RANGE for negative/NaN values and ERR_INVALID_ARG_TYPE for non-number values (was incorrectly throwing ERR_INVALID_ARG_VALUE for all)
  • Implement kill ring with yank (Ctrl+Y) and yank-pop (Meta+Y)
  • Implement undo/redo (Ctrl+_ / Ctrl+^)
  • Fix write() after close() to throw ERR_USE_AFTER_CLOSE
  • Fix question() abort signal cleanupremoveEventListener was missing the event name arg, and the callback wrapper had an infinite recursion bug

Test plan

  • cargo test --test node_compat test-readline — 18 pass (up from 16), 4 remaining failures are unrelated deeper issues (internal ESM module resolution, watermark data, promises abort-on-close)
  • Fixes test-readline-tab-complete.js and test-readline-promises-tab-complete.js

🤖 Generated with Claude Code

- Fix tab completion column formatting (Math.max.apply was missing args)
- Fix historySize validation to throw ERR_OUT_OF_RANGE for negative/NaN
  values and ERR_INVALID_ARG_TYPE for non-number values
- Implement kill ring with yank (Ctrl+Y) and yank-pop (Meta+Y)
- Implement undo (Ctrl+_) and redo (Ctrl+^)
- Fix write() to throw ERR_USE_AFTER_CLOSE after close()
- Fix question() abort signal cleanup: use correct removeEventListener
  args and prevent infinite recursion in callback

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@kajukitli kajukitli left a comment

Choose a reason for hiding this comment

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

lgtm — nice collection of readline fixes

verified:

  • Math.max(...completionsWidth) fix is correct (was missing spread)
  • removeEventListener fix — was indeed missing the event name arg
  • infinite recursion fix in callback wrapper by capturing originalCb
  • historySize validation now correctly distinguishes type vs range errors
  • kill ring + undo/redo implementation looks solid

minor nit: the undo stack could grow unbounded if users type a lot, but that's an edge case and matches how most editors work anyway

Copy link
Copy Markdown
Member

@nathanwhit nathanwhit left a comment

Choose a reason for hiding this comment

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

LGTM

@bartlomieju bartlomieju merged commit e76e5fa into denoland:main Mar 9, 2026
112 checks passed
@bartlomieju bartlomieju deleted the fix/readline-improvements branch March 9, 2026 22:07
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.

3 participants