fix: magnifier cursor visible, line nums hidden, M-x/which-key safe

This commit is contained in:
2026-02-22 23:03:16 +01:00
parent a71e212d81
commit d3747f71c4

View File

@@ -850,21 +850,34 @@ Keeps the status bar and tab bar fully visible at any zoom level.")
(defun my/mag--switch-source () (defun my/mag--switch-source ()
"Switch magnifier to track the current buffer." "Switch magnifier to track the current buffer."
(let* ((new-source (current-buffer)) (cl-block my/mag--switch-source
(mag-name (format "*mag:%s*" (buffer-name new-source)))) (let* ((new-source (current-buffer))
(my/mag--kill-indirect) (mag-name (format "*mag:%s*" (buffer-name new-source))))
(setq my/mag--source new-source) ;; Don't switch to transient/minibuffer buffers
(setq my/mag--buffer (make-indirect-buffer new-source mag-name t)) (when (or (minibufferp new-source)
(when (and my/mag--window (window-live-p my/mag--window)) (string-prefix-p " " (buffer-name new-source)))
(set-window-buffer my/mag--window my/mag--buffer) (cl-return-from my/mag--switch-source))
(with-selected-window my/mag--window (my/mag--kill-indirect)
(text-scale-set my/mag--zoom-level) (setq my/mag--source new-source)
(setq-local cursor-type nil) (setq my/mag--buffer (make-indirect-buffer new-source mag-name t))
(setq-local scroll-margin 0))))) (when (and my/mag--window (window-live-p my/mag--window))
(set-window-buffer my/mag--window my/mag--buffer)
(with-selected-window my/mag--window
(text-scale-set my/mag--zoom-level)
(setq-local cursor-type 'box)
(setq-local scroll-margin 0)
(when (bound-and-true-p display-line-numbers-mode)
(display-line-numbers-mode -1))
(when (bound-and-true-p hl-line-mode)
(hl-line-mode -1)))))))
(defun my/mag--sync () (defun my/mag--sync ()
"Sync magnified pane to current cursor position." "Sync magnified pane to current cursor position."
(when my/mag--active (when my/mag--active
;; Skip when minibuffer is active (M-x, vertico, which-key, etc.)
(when (or (active-minibuffer-window)
(window-minibuffer-p))
(cl-return-from my/mag--sync))
;; Ignore if we're in the magnifier pane itself ;; Ignore if we're in the magnifier pane itself
(when (eq (selected-window) my/mag--window) (when (eq (selected-window) my/mag--window)
(cl-return-from my/mag--sync)) (cl-return-from my/mag--sync))
@@ -884,6 +897,7 @@ Keeps the status bar and tab bar fully visible at any zoom level.")
(defun my/mag--on-window-change () (defun my/mag--on-window-change ()
"Clean up if magnifier window was closed by user." "Clean up if magnifier window was closed by user."
(when (and my/mag--active (when (and my/mag--active
(not (active-minibuffer-window))
(not (and my/mag--window (window-live-p my/mag--window)))) (not (and my/mag--window (window-live-p my/mag--window))))
(my/mag--disable))) (my/mag--disable)))
@@ -904,8 +918,12 @@ Keeps the status bar and tab bar fully visible at any zoom level.")
(set-window-buffer my/mag--window my/mag--buffer) (set-window-buffer my/mag--window my/mag--buffer)
(with-selected-window my/mag--window (with-selected-window my/mag--window
(text-scale-set my/mag--zoom-level) (text-scale-set my/mag--zoom-level)
(setq-local cursor-type nil) (setq-local cursor-type 'box)
(setq-local scroll-margin 0)) (setq-local scroll-margin 0)
(when (bound-and-true-p display-line-numbers-mode)
(display-line-numbers-mode -1))
(when (bound-and-true-p hl-line-mode)
(hl-line-mode -1)))
(setq my/mag--active t) (setq my/mag--active t)
(add-hook 'post-command-hook #'my/mag--sync) (add-hook 'post-command-hook #'my/mag--sync)
(add-hook 'window-configuration-change-hook #'my/mag--on-window-change) (add-hook 'window-configuration-change-hook #'my/mag--on-window-change)