]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix show-paren-mode when the parentheses is partially visible
authorEli Zaretskii <eliz@gnu.org>
Mon, 10 Jul 2023 14:15:21 +0000 (17:15 +0300)
committerEli Zaretskii <eliz@gnu.org>
Mon, 10 Jul 2023 14:15:21 +0000 (17:15 +0300)
* lisp/paren.el (show-paren-function): Support the case where the
open paren is partially visible, but enough so to not consider it
"off-screen".  (Bug#64547)

lisp/paren.el

index 4c91fd294900cedda222088b840be9c5d4bd6cdf..54a2c23f17fa861d5d370f7281bfdfe24f8554a6 100644 (file)
@@ -506,7 +506,19 @@ It is the default value of `show-paren-data-function'."
             (when (and show-paren-context-when-offscreen
                        (not (eql show-paren--last-pos (point)))
                        (< there-beg here-beg)
-                       (not (pos-visible-in-window-p openparen)))
+                       ;; Either OPENPAREN position is fully visible...
+                       (not (or (pos-visible-in-window-p openparen)
+                                (let ((dfh4 (* 0.25 (default-font-height)))
+                                      (part
+                                       (pos-visible-in-window-p openparen
+                                                                nil t)))
+                                  ;; ...or partially visible, and the
+                                  ;; invisible part is less than 1/4th
+                                  ;; of the default font height
+                                  (or (< (length part) 4)
+                                      (and
+                                       (< (nth 2 part) dfh4)
+                                       (< (nth 3 part) dfh4)))))))
               (let ((context (blink-paren-open-paren-line-string
                               openparen))
                     (message-log-max nil))