fix: make cursor visible on newline characters in multi-line input (#689)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Charles Packer
2026-01-26 15:33:10 -08:00
committed by GitHub
parent 83cdccd930
commit b281396b18

View File

@@ -74,7 +74,13 @@ function TextInput({ value: originalValue, placeholder = '', focus = true, mask,
renderedValue = value.length > 0 ? '' : chalk.inverse(' ');
let i = 0;
for (const char of value) {
renderedValue += i >= cursorOffset - cursorActualWidth && i <= cursorOffset ? chalk.inverse(char) : char;
const isCursorPosition = i >= cursorOffset - cursorActualWidth && i <= cursorOffset;
if (isCursorPosition && char === '\n') {
// Newline at cursor: show inverted space (visible cursor) then the newline
renderedValue += chalk.inverse(' ') + char;
} else {
renderedValue += isCursorPosition ? chalk.inverse(char) : char;
}
i++;
}
if (value.length > 0 && cursorOffset === value.length) {