From ed49daca32efeca9c99477c35766791c83812c66 Mon Sep 17 00:00:00 2001 From: lugui Date: Thu, 17 Apr 2025 23:19:45 +0000 Subject: [PATCH] feat: update position of cursor when navigating input history with arrow keys to the end of the text (#255) Updated the position of the cursor on the user input box to be at the end of the text when the user uses the arrow keys to navigate through the input history in order to better match the behavior of a terminal. --- codex-cli/src/components/vendor/ink-text-input.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/codex-cli/src/components/vendor/ink-text-input.tsx b/codex-cli/src/components/vendor/ink-text-input.tsx index c274caa1..c516799a 100644 --- a/codex-cli/src/components/vendor/ink-text-input.tsx +++ b/codex-cli/src/components/vendor/ink-text-input.tsx @@ -105,8 +105,11 @@ function TextInput({ } const newValue = originalValue || ""; - - if (previousState.cursorOffset > newValue.length - 1) { + // Sets the cursor to the end of the line if the value is empty or the cursor is at the end of the line. + if ( + previousState.cursorOffset === 0 || + previousState.cursorOffset > newValue.length - 1 + ) { return { cursorOffset: newValue.length, cursorWidth: 0,