1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Inherit text props in Completion Preview insertion commands

When completing with Completion Preview mode commands,
inherit text properties from surrounding text similarly to
other completion commands, such as 'completion-at-point'.

* lisp/completion-preview.el (completion-preview-insert)
(completion-preview-partial-insert)
(completion-preview-complete): Use 'insert-and-inherit'
instead of 'insert' to insert text for completion.
* test/lisp/completion-preview-tests.el
(completion-preview-insert-inherits-text-properties): New
test.
This commit is contained in:
Eshel Yaron 2024-06-29 11:51:10 +02:00
parent 3088b06759
commit 2119cd52cd
No known key found for this signature in database
GPG key ID: EF3EE9CA35D78618
2 changed files with 16 additions and 3 deletions

View file

@ -432,4 +432,17 @@ instead."
(should-not exit-fn-called)
(should-not exit-fn-args))))
(ert-deftest completion-preview-insert-inherits-text-properties ()
"Test that `completion-preview-insert' inherits text properties."
(with-temp-buffer
(setq-local completion-at-point-functions
(list (completion-preview-tests--capf '("foobar" "foobaz"))))
(insert (propertize "foo" 'prop 'val))
(let ((this-command 'self-insert-command))
(completion-preview--post-command))
(completion-preview-tests--check-preview "bar" 'completion-preview-common)
(completion-preview-insert)
(should (string= (buffer-string) "foobar"))
(should (eq (get-text-property 6 'prop) 'val))))
;;; completion-preview-tests.el ends here