fix(tui): editor: sanitize pasted paths

Ayman Bagabas created

Some terminals may add a trailing space to pasted paths preventing the
editor from recognizing them as valid file paths. This commit ensures
that pasted paths are trimmed of leading and trailing spaces for paths.

Change summary

internal/tui/components/chat/editor/editor.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Detailed changes

internal/tui/components/chat/editor/editor.go 🔗

@@ -228,7 +228,7 @@ func (m *editorCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 	case tea.PasteMsg:
 		path := strings.ReplaceAll(string(msg), "\\ ", " ")
 		// try to get an image
-		path, err := filepath.Abs(path)
+		path, err := filepath.Abs(strings.TrimSpace(path))
 		if err != nil {
 			m.textarea, cmd = m.textarea.Update(msg)
 			return m, cmd