Skip to content

Commit bc69a0c

Browse files
author
Kang Tu
committed
fix: trim trailing newlines from region when sending to AI
1 parent 1dcf639 commit bc69a0c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ai-code-interface.el

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ with a newline separator."
6868
"Read a prompt from the user and send it to the AI service."
6969
(interactive)
7070
(let ((initial-input (when (use-region-p)
71-
(buffer-substring-no-properties (region-beginning)
72-
(region-end)))))
71+
(string-trim-right
72+
(buffer-substring-no-properties (region-beginning)
73+
(region-end))
74+
"\n"))))
7375
(when-let ((prompt (ai-code-read-string "Send to AI: " initial-input)))
7476
(ai-code--insert-prompt prompt))))
7577

0 commit comments

Comments
 (0)