diff options
| author | Aiden Cline <[email protected]> | 2025-06-24 18:13:15 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-24 18:13:15 -0500 |
| commit | 0b1a8ae699a4bccc379f7f6569171163e1caa7cf (patch) | |
| tree | 08f69493f1af9d6dec576f1039e4b4fbda9dbdd4 /packages | |
| parent | eb70b1e5c808e379041bbad3e7afb51430a2c7f1 (diff) | |
| download | opencode-0b1a8ae699a4bccc379f7f6569171163e1caa7cf.tar.gz opencode-0b1a8ae699a4bccc379f7f6569171163e1caa7cf.zip | |
fix: file completions replaced wrong text when paths overlap (#378)
Diffstat (limited to 'packages')
| -rw-r--r-- | packages/tui/.gitignore | 1 | ||||
| -rw-r--r-- | packages/tui/internal/components/chat/editor.go | 11 |
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 } } |
