- (let ((beg (overlay-start completion-preview--overlay))
- (end (point))
- (after (overlay-get completion-preview--overlay 'after-string))
- (data (overlay-get completion-preview--overlay 'completion-preview-data)))
- (if (and (< beg end (+ beg (length after)))
- (string-prefix-p (buffer-substring beg end) after))
- (overlay-put (completion-preview--make-overlay end (substring after (- end beg)))
- 'completion-preview-data
- (append (list (nth 0 data) end (nth 2 data))
- (nthcdr 3 data)))
+ (let* ((data (overlay-get completion-preview--overlay 'completion-preview-data))
+ (beg (car data))
+ (cands (caddr data))
+ (cand (car cands))
+ (plist (cdddr data))
+ (len (length cand))
+ (end (+ beg len))
+ (after (overlay-get completion-preview--overlay 'after-string))
+ (face (get-text-property 0 'face after)))
+ (if (and (< beg (point) end)
+ (string-prefix-p (buffer-substring beg (point)) cand))
+ (overlay-put
+ (completion-preview--make-overlay
+ (point) (propertize (substring cand (- (point) beg)) 'face face))
+ 'completion-preview-data (append (list beg (point) cands) plist))