enhance: support trigger shortcut without enter event#457
Conversation
✅ Deploy Preview for rstest-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the CLI shortcuts functionality by enabling immediate trigger of shortcuts without requiring the Enter key. The change switches from using 'line' events to 'keypress' events for a more responsive user experience.
Key changes:
- Replace line-based input handling with raw keypress detection
- Update user-facing messages to remove "+ enter" from shortcut descriptions
- Implement proper raw mode handling with cleanup functions
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/core/src/core/runTests.ts | Updates CLI shortcut help messages to remove "+ enter" references |
| packages/core/src/core/cliShortcuts.ts | Replaces readline 'line' event with raw keypress handling for immediate shortcut responses |
| } | ||
| }; | ||
|
|
||
| process.stdin.on('keypress', handleKeypress); |
There was a problem hiding this comment.
The 'keypress' event is not available by default in Node.js. You need to import and use the 'keypress' module or handle raw stdin data directly. Consider using process.stdin.on('data', ...) instead or import a keypress library.
| process.stdin.on('keypress', handleKeypress); | |
| process.stdin.on('data', handleKeypress); |
| process.stdin.resume(); | ||
| process.stdin.setEncoding('utf8'); | ||
|
|
||
| const handleKeypress = ( |
There was a problem hiding this comment.
The key parameter with properties like name, ctrl, meta, and shift suggests this is expecting a parsed key object, but raw stdin data will only provide the raw string/buffer. The key parameter structure doesn't match what raw stdin provides.
| key: { name: string; ctrl: boolean; meta: boolean; shift: boolean }, | ||
| ) => { | ||
| // Handle Ctrl+C | ||
| if (key.ctrl && key.name === 'c') { |
There was a problem hiding this comment.
When using raw mode with stdin data events, Ctrl+C will be received as a raw character (\u0003) rather than a parsed key object. This condition will never be true with the current implementation.
| if (key.ctrl && key.name === 'c') { | |
| if (str === '\u0003') { |
Summary
support trigger shortcut without
enter, usekeypressinstead oflineevent.Related Links
Checklist