diff --git a/internal/tui/components/chat/editor/editor.go b/internal/tui/components/chat/editor/editor.go index b3669d826068156ea4be0ed5b9b0f5c12ea1d30c..ebdc4c199554178298f97e516de432378e220594 100644 --- a/internal/tui/components/chat/editor/editor.go +++ b/internal/tui/components/chat/editor/editor.go @@ -200,21 +200,21 @@ func onCompletionItemSelect(fsys fs.FS, item FileCompletionItem, insert bool, m word := m.textarea.Word() // If the selected item is a file, insert its path into the textarea - value := m.textarea.Value() - value = value[:m.completionsStartIndex] // Remove the current query + originalValue := m.textarea.Value() + newValue := originalValue[:m.completionsStartIndex] // Remove the current query if cmd == nil { - value += path // insert the file path + newValue += path // insert the file path for non-images } - value += value[m.completionsStartIndex+len(word):] // Append the rest of the value + newValue += originalValue[m.completionsStartIndex+len(word):] // Append the rest of the value // XXX: This will always move the cursor to the end of the textarea. - m.textarea.SetValue(value) + m.textarea.SetValue(newValue) m.textarea.MoveToEnd() if !insert { m.isCompletionsOpen = false m.currentQuery = "" m.completionsStartIndex = 0 } - + return m, cmd }