fix(syntax): flycheck popups clearing active region

Moving the cursor over a flycheck-highlighted error will display the
error message in a popup. Displaying that popup could clear the active
selection (#7242), which is disruptive. This only affected non-Evil
users and users not using the module's +childframe flag, but should no
longer affect anyone after this commit.

Fix: #7242
Ref: flycheck/flycheck-popup-tip#14
This commit is contained in:
Henrik Lissner 2024-04-07 16:41:37 -04:00 committed by Yann Esposito (Yogsototh)
parent bf860138f2
commit fdf2da903c
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646

View file

@ -51,16 +51,19 @@
:hook (flycheck-mode . +syntax-init-popups-h)
:config
(setq flycheck-popup-tip-error-prefix "X ")
(after! evil
;; Don't display popups while in insert or replace mode, as it can affect
;; the cursor's position or cause disruptive input delays.
(add-hook! '(evil-insert-state-entry-hook evil-replace-state-entry-hook)
#'flycheck-popup-tip-delete-popup)
;; HACK: Only display the flycheck popup if we're in normal mode (for evil
;; users) or if no selection or completion is active. This popup can
;; interfere with the active evil mode, clear active regions, and other
;; funny business (see #7242).
(defadvice! +syntax--disable-flycheck-popup-tip-maybe-a (&rest _)
:before-while #'flycheck-popup-tip-show-popup
(if evil-local-mode
(eq evil-state 'normal)
(not (bound-and-true-p company-backend))))))
(if (and (bound-and-true-p evil-local-mode)
(not (evil-emacs-state-p)))
(evil-normal-state-p)
(and (not (region-active-p))
(not (bound-and-true-p company-backend))
(not (ignore-errors (>= corfu--index 0)))))))
(use-package! flycheck-posframe