Skip to content

Commit ee56653

Browse files
author
Kang Tu
committed
fix clipboard
1 parent 1599480 commit ee56653

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

ai-code-interface.el

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,14 @@ with a newline separator."
7373

7474
(defun ai-code--get-clipboard-text ()
7575
"Return the current clipboard contents as a plain string, or nil if unavailable."
76-
(let ((selection (when (fboundp 'gui-get-selection)
77-
(or (gui-get-selection 'CLIPBOARD 'UTF8_STRING)
78-
(gui-get-selection 'CLIPBOARD 'STRING))))
79-
(kill-text (condition-case nil
80-
(current-kill 0 t)
81-
(error nil))))
76+
(let* ((selection (when (fboundp 'gui-get-selection)
77+
(or (let ((text (gui-get-selection 'CLIPBOARD 'UTF8_STRING)))
78+
(and (stringp text) (not (string-empty-p text)) text))
79+
(let ((text (gui-get-selection 'CLIPBOARD 'STRING)))
80+
(and (stringp text) (not (string-empty-p text)) text)))))
81+
(kill-text (condition-case nil
82+
(current-kill 0 t)
83+
(error nil))))
8284
(let ((text (or selection kill-text)))
8385
(when (stringp text)
8486
(substring-no-properties text)))))

0 commit comments

Comments
 (0)