(str (concat pre com (nth ind all))))
(completion-preview-active-mode -1)
(goto-char end)
- (insert (substring-no-properties aft))
+ (insert-and-inherit (substring-no-properties aft))
(when (functionp efn) (funcall efn str 'finished))))
(defun completion-preview-partial-insert (fun &rest args)
(save-excursion
(goto-char end)
;; Temporarily insert the full completion candidate.
- (insert (substring-no-properties aft)))
+ (insert-and-inherit (substring-no-properties aft)))
;; Set point to the end of the prefix that we want to keep.
(apply fun args)
(unless (< end (point))
(completion-preview--inhibit-update)
(completion-at-point))
;; Otherwise, insert the common prefix and update the preview.
- (insert ins)
+ (insert-and-inherit ins)
(let ((suf (nth cur all))
(pos (point)))
(if (or (string-empty-p suf) (null suf))
(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))))
+
(ert-deftest completion-preview-cursor-type ()
"Test modification of `cursor-type' when completion preview is visible."
(with-temp-buffer