From 4821da1ad7fe0f30cb4d41669ad2db8652fcfa79 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 10 Jul 2023 17:15:21 +0300 Subject: [PATCH] Fix show-paren-mode when the parentheses is partially visible * 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 | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lisp/paren.el b/lisp/paren.el index 4c91fd29490..54a2c23f17f 100644 --- a/lisp/paren.el +++ b/lisp/paren.el @@ -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)) -- 2.39.2