summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--packages/tui/.gitignore1
-rw-r--r--packages/tui/internal/components/chat/editor.go11
2 files changed, 10 insertions, 2 deletions
diff --git a/packages/tui/.gitignore b/packages/tui/.gitignore
new file mode 100644
index 000000000..aac2e0bdc
--- /dev/null
+++ b/packages/tui/.gitignore
@@ -0,0 +1 @@
+opencode-test
diff --git a/packages/tui/internal/components/chat/editor.go b/packages/tui/internal/components/chat/editor.go
index d67a226fe..b5d1cc034 100644
--- a/packages/tui/internal/components/chat/editor.go
+++ b/packages/tui/internal/components/chat/editor.go
@@ -80,8 +80,15 @@ func (m *editorComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, tea.Batch(cmds...)
} else {
existingValue := m.textarea.Value()
- modifiedValue := strings.Replace(existingValue, msg.SearchString, msg.CompletionValue, 1)
- m.textarea.SetValue(modifiedValue + " ")
+
+ // Replace the current token (after last space)
+ lastSpaceIndex := strings.LastIndex(existingValue, " ")
+ if lastSpaceIndex == -1 {
+ m.textarea.SetValue(msg.CompletionValue + " ")
+ } else {
+ modifiedValue := existingValue[:lastSpaceIndex+1] + msg.CompletionValue
+ m.textarea.SetValue(modifiedValue + " ")
+ }
return m, nil
}
}