feat: place caret inside inserted function parentheses\n\n- Add CaretIndex to MainViewModel and bind TextBox.CaretIndex\n- After function insertion, set caret to inside parentheses\n- Return focus to input box for immediate typing

This commit is contained in:
Codex CLI 2025-09-01 03:01:10 -05:00
commit b8ba57a707
3 changed files with 15 additions and 1 deletions

View file

@ -35,6 +35,10 @@ public partial class MainViewModel : ViewModelBase
[ObservableProperty]
private int _selectedHistoryIndex = -1;
// Caret position in the input TextBox
[ObservableProperty]
private int _caretIndex;
public ObservableCollection<HistoryItem> History { get; }
public ObservableCollection<VariableItem> Variables { get; }
@ -61,6 +65,11 @@ public partial class MainViewModel : ViewModelBase
if (string.IsNullOrWhiteSpace(functionDefintionItem.FunctionName))
return;
InsertToken(functionDefintionItem.FunctionName + "()");
// Place caret inside the parentheses
if (!string.IsNullOrEmpty(InputText))
{
CaretIndex = Math.Max(0, InputText.Length - 1);
}
// Close the functions flyout after insertion for smoother UX
IsFunctionsPanelOpen = false;
}