fix: reset cursor to column 0 after inquirer prompts on Windows#278
Merged
Conversation
On Windows terminals, inquirer leaves the cursor at the end of the rendered answer text after a prompt completes. When the answer wraps across multiple lines (e.g. checkbox with several editors selected), subsequent console output starts at the wrong horizontal offset because \n moves the cursor down without resetting to column 0. Fix by calling cursorTo(process.stdout, 0) from node:readline after each prompt returns, guarded by process.stdout.isTTY. Applied to both promptEditorSelection() and promptSingleEditorSelection() in src/helpers/editor-detect.ts. Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Verify that promptEditorSelection() and promptSingleEditorSelection() call cursorTo(process.stdout, 0) when stdout is a TTY, and skip the call when stdout is piped. Uses mock.module to intercept node:readline and inquirer for isolated, non-interactive testing. Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Deploying archgate-cli with
|
| Latest commit: |
482a0b4
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://33fdd5ba.archgate-cli.pages.dev |
| Branch Preview URL: | https://fix-inquirer-cursor-position.archgate-cli.pages.dev |
Inquirer's shared close path (prompt.js onClose) writes cursorShow + rl.close() without resetting the cursor column. On Windows terminals this causes garbled output after ANY prompt whose rendered answer wraps past the terminal width. Apply the same cursorTo(process.stdout, 0) fix to: - login-flow.ts (4 prompts: email, editor, use case, confirm) - init.ts (1 prompt: want plugin confirm) - adr/create.ts (1 prompt: domain/title/files) Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
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.
Summary
onClosepath (prompt.js:210-212) writescursorShow+rl.close()but never resets the cursor column to 0. This affects ALL prompt types (checkbox, list, input, confirm).cursorTo(process.stdout, 0)fromnode:readlineafter everyinquirer.prompt()call, guarded byprocess.stdout.isTTY.Files fixed
src/helpers/editor-detect.tssrc/helpers/login-flow.tssrc/commands/init.tssrc/commands/adr/create.tsTotal: 8 prompt sites across 4 files, covering every
inquirer.prompt()call in the codebase.Test plan
bun run validatepasses (lint, typecheck, format, 729 tests, 23/23 ADR checks, build)promptEditorSelectionandpromptSingleEditorSelectionverifycursorTo(stdout, 0)is called (TTY) / not called (non-TTY)archgate plugin installon Windows — output lines should start at column 0archgate loginon Windows — signup prompts should not garble subsequent outputarchgate adr createon Windows — output after interactive prompts is clean