Skip to content

Commit 5df4da1

Browse files
authored
fix(cli): fix Prompt.text clear when input wraps terminal lines (#6022)
1 parent e71889f commit 5df4da1

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

.changeset/fix-prompt-text-wrap.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@effect/cli": patch
3+
---
4+
5+
Fixed `Prompt.text` rendering duplicate lines when input text wraps to a new terminal line.

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)