From e740e5478a43358fbbd79636483d000e01f88b7e Mon Sep 17 00:00:00 2001 From: citrons Date: Sun, 1 Jun 2025 15:30:36 -0500 Subject: clear selection when setting input contents --- tui/text_input.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tui/text_input.go') diff --git a/tui/text_input.go b/tui/text_input.go index ba99f48..63335aa 100644 --- a/tui/text_input.go +++ b/tui/text_input.go @@ -22,6 +22,7 @@ func (t *TextInput) Text() string { func (t *TextInput) SetText(text string) { t.beforeCursor = "" t.afterCursor = text + t.selection = "" } func toGraphemes(s string) []string { @@ -167,6 +168,10 @@ func (t *TextInput) Write(text string) { t.beforeCursor += text } +func (t *TextInput) IsEmpty() bool { + return t.beforeCursor == "" && t.selection == "" && t.afterCursor == "" +} + func (t *TextInput) Update(ev Event) (usedKeybind bool) { if Selected != t.id { t.Deselect() -- cgit v1.2.3