From 4a4db727bbfec305d0658c50f79b54cb0eb00d83 Mon Sep 17 00:00:00 2001 From: materus Date: Thu, 15 May 2025 23:19:28 +0200 Subject: [PATCH] Fix resize crash, add pixel scroll precision support --- corfu-mouse.el | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/corfu-mouse.el b/corfu-mouse.el index 2aed0a9..d5843f0 100644 --- a/corfu-mouse.el +++ b/corfu-mouse.el @@ -75,8 +75,7 @@ (defun corfu-mouse--format-candidates (fcands) "Format candidates. - -FCANDS is the return value of `corfu--format-candidates'." + FCANDS is the return value of `corfu--format-candidates'." (let ((index corfu--scroll) (cands (caddr fcands))) (while cands @@ -84,9 +83,10 @@ FCANDS is the return value of `corfu--format-candidates'." ;; Append necessary amount of spaces to make it as wide as the ;; popup. - (setq line (concat line (make-string (- (cadr fcands) - (string-width line)) - ? ))) + (let ((strlen (- (cadr fcands) (string-width line)))) + (when (> strlen 0) + (setq line (concat line (make-string strlen ? ))))) + (add-text-properties 0 (length line) `(mouse-face corfu-mouse @@ -116,6 +116,8 @@ FCANDS is the return value of `corfu--format-candidates'." "Setup mouse scrolling on BUFFER." (let ((current-buffer (current-buffer))) (with-current-buffer buffer + (when (boundp 'pixel-scroll-precision-mode) + (setq-local pixel-scroll-precision-mode nil)) (setq-local mwheel-scroll-up-function #'corfu-mouse--scroll-up) (setq-local mwheel-scroll-down-function #'corfu-mouse--scroll-down)