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:
parent
2c7670f06c
commit
b8ba57a707
3 changed files with 15 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue