Skip to content

Commit a7640b2

Browse files
committed
fix(cli): fix Prompt.text clear when input wraps terminal lines
When the user's input in `Prompt.text` exceeds the terminal width and wraps to a new line, `renderClearScreen` miscalculates lines to erase because it only considers `options.message`, not the full rendered line including the input value. This causes duplicate prompt lines to be printed on each keystroke after the text wraps. The fix calculates the full rendered line length: `"? " + message + " › " + inputValue` This is the same root cause as #5978 (for Prompt.select), and applies the equivalent fix to Prompt.text. Closes #5978
1 parent 7b8165f commit a7640b2

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

  • packages/cli/src/internal/prompt

packages/cli/src/internal/prompt/text.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ function renderClearScreen(state: State, options: Options) {
4949
)
5050
})
5151
// Ensure that the prior prompt output is cleaned up
52-
const clearOutput = InternalAnsiUtils.eraseText(options.message, columns)
52+
// Calculate full rendered line: "? " + message + " › " + input
53+
const inputValue = state.value.length > 0 ? state.value : options.default
54+
const fullLine = `? ${options.message} \u203a ${inputValue}`
55+
const clearOutput = InternalAnsiUtils.eraseText(fullLine, columns)
5356
// Concatenate and render all documents
5457
return clearError.pipe(
5558
Doc.cat(clearOutput),

0 commit comments

Comments
 (0)