branch: externals/corfu commit c1870977f6a9107cef59c482446fca60991dfd4b Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
Workaround for bug#50470: Fix misbehaving Capfs - Ensure that Capfs do not manipulate the buffer - Redirect illegal calls to completion-in-region --- corfu.el | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/corfu.el b/corfu.el index a36d119..0b5cc91 100644 --- a/corfu.el +++ b/corfu.el @@ -1153,7 +1153,19 @@ there hasn't been any input, then quit." (defun corfu--capf-wrapper (fun) "Wrapper for `completion-at-point' FUN. Determines if the capf is applicable at the current position." - (pcase (funcall fun) + (pcase + ;; bug#50470: Fix Capfs which illegally modify the buffer + ;; or which illegally call `completion-in-region' + (catch 'corfu--illegal-completion-in-region + (condition-case nil + (let ((buffer-read-only t) + (inhibit-read-only nil) + (completion-in-region-function + (lambda (beg end coll pred) + (throw 'corfu--illegal-completion-in-region + (list beg end coll :predicate pred))))) + (funcall fun)) + (buffer-read-only nil))) ((and res `(,beg ,end ,table . ,plist)) (and (integer-or-marker-p beg) ;; Valid capf result (<= beg (point) end) ;; Sanity checking