diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2023-12-06 16:48:50 +0100 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2023-12-06 16:48:50 +0100 |
| commit | dd0d88f52fd9f1edd38f541706ab03c8ca5b9f5c (patch) | |
| tree | 5a0bc094d47e660295d2fde71568f0cab03fae66 | |
| parent | 24dccafeea114b1aec7118f2a8405b46aa0051e0 (diff) | |
corfu-complete: Use returned candidate from corfu--insert
| -rw-r--r-- | corfu.el | 32 |
1 files changed, 15 insertions, 17 deletions
@@ -1016,7 +1016,8 @@ A scroll bar is displayed from LO to LO+BAR." ;; bug#55205: completion--replace removes properties! (completion--replace beg end (concat str)) (corfu--goto -1) ;; Reset selection, but continue completion. - (when status (corfu--done str status)))) ;; Exit with status + (when status (corfu--done str status)) ;; Exit with status + str)) (cl-defgeneric corfu--affixate (cands) "Annotate CANDS with annotation function." @@ -1209,22 +1210,19 @@ If a candidate is selected, insert it." (interactive) (pcase-let ((`(,beg ,end ,table ,pred) completion-in-region--data)) (if (>= corfu--index 0) - ;; Continue completion with selected candidate - (progn - (corfu--insert nil) - ;; Exit with status 'finished if input is a valid match and no further - ;; completion is possible. Furthermore treat the completion as - ;; finished if we are at the end of a boundary, even if other longer - ;; candidates would still match, since the user invoked `corfu-complete' - ;; with an explicitly selected candidate! - (let ((newstr (buffer-substring-no-properties beg end))) - (when (and (test-completion newstr table pred) - (or - (not (consp (completion-try-completion - newstr table pred (length newstr) - (completion-metadata newstr table pred)))) - (equal (completion-boundaries newstr table pred "") '(0 . 0)))) - (corfu--done newstr 'finished)))) + ;; Continue completion with selected candidate. Exit with status + ;; 'finished if input is a valid match and no further completion is + ;; possible. Furthermore treat the completion as finished if we are at + ;; the end of a boundary, even if other longer candidates would still + ;; match, since the user invoked `corfu-complete' with an explicitly + ;; selected candidate! + (let ((newstr (corfu--insert nil))) + (when (and (test-completion newstr table pred) + (or (not (consp (completion-try-completion + newstr table pred (length newstr) + (completion-metadata newstr table pred)))) + (equal (completion-boundaries newstr table pred "") '(0 . 0)))) + (corfu--done newstr 'finished))) ;; Try to complete the current input string (let* ((pt (max 0 (- (point) beg))) (str (buffer-substring-no-properties beg end)) |
