fix(editor): correctly insert full path for non images remove for images

tauraamui created

Change summary

internal/tui/components/chat/editor/editor.go | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

Detailed changes

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
 }