fix(display): keep top borders within the mounted line grid
Some checks are pending
CI / test (29.1) (push) Waiting to run
CI / test (30.2) (push) Waiting to run
CI / native-build (macos-latest) (push) Waiting to run
CI / native-build (ubuntu-latest) (push) Waiting to run
CI / native-build (windows-latest) (push) Waiting to run
CI / native-msrv (macos-latest) (push) Waiting to run
CI / native-msrv (ubuntu-latest) (push) Waiting to run
CI / native-msrv (windows-latest) (push) Waiting to run
Some checks are pending
CI / test (29.1) (push) Waiting to run
CI / test (30.2) (push) Waiting to run
CI / native-build (macos-latest) (push) Waiting to run
CI / native-build (ubuntu-latest) (push) Waiting to run
CI / native-build (windows-latest) (push) Waiting to run
CI / native-msrv (macos-latest) (push) Waiting to run
CI / native-msrv (ubuntu-latest) (push) Waiting to run
CI / native-msrv (windows-latest) (push) Waiting to run
This commit is contained in:
parent
23bf6052ab
commit
4d0d46d5be
@ -403,6 +403,9 @@ rather than relying on an implicit default.")
|
|||||||
(:symbol ebox-native-status--diagnosis
|
(:symbol ebox-native-status--diagnosis
|
||||||
:reason buffer-local-native-status-diagnostic
|
:reason buffer-local-native-status-diagnostic
|
||||||
:evidence status-buffer-presentation-only)
|
:evidence status-buffer-presentation-only)
|
||||||
|
(:symbol ebox--saved-overline-margin
|
||||||
|
:reason buffer-local-native-display-preference
|
||||||
|
:evidence mode-lifetime-preference-restoration-not-render-generation-state)
|
||||||
(:symbol ebox-surface--observation-context
|
(:symbol ebox-surface--observation-context
|
||||||
:reason dynamically-bound-publication-observation
|
:reason dynamically-bound-publication-observation
|
||||||
:evidence let-bound-for-one-public-ebox-call)
|
:evidence let-bound-for-one-public-ebox-call)
|
||||||
|
|||||||
20
ebox.el
20
ebox.el
@ -4787,14 +4787,30 @@ Examples:
|
|||||||
(memq (car entry) ebox--scroll-overridden-minor-modes))
|
(memq (car entry) ebox--scroll-overridden-minor-modes))
|
||||||
minor-mode-overriding-map-alist)))
|
minor-mode-overriding-map-alist)))
|
||||||
|
|
||||||
|
(defvar-local ebox--saved-overline-margin nil
|
||||||
|
"Original local-binding flag and value of `overline-margin' while mounted.")
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(define-minor-mode ebox-buffer-mode
|
(define-minor-mode ebox-buffer-mode
|
||||||
"Minor mode for interactive ebox buffers."
|
"Minor mode for interactive ebox buffers."
|
||||||
:lighter " Ebox"
|
:lighter " Ebox"
|
||||||
:keymap ebox-scroll-map
|
:keymap ebox-scroll-map
|
||||||
(if ebox-buffer-mode
|
(if ebox-buffer-mode
|
||||||
(ebox--install-scroll-map-overrides)
|
(progn
|
||||||
(ebox--clear-scroll-map-overrides)))
|
(unless ebox--saved-overline-margin
|
||||||
|
(setq ebox--saved-overline-margin
|
||||||
|
(cons (local-variable-p 'overline-margin) overline-margin)))
|
||||||
|
;; Native overlines otherwise add ascent to whichever row currently
|
||||||
|
;; contains a top border. Paint inside the measured line grid so
|
||||||
|
;; moving a positioned border cannot move the surrounding rows.
|
||||||
|
(setq-local overline-margin 0)
|
||||||
|
(ebox--install-scroll-map-overrides))
|
||||||
|
(ebox--clear-scroll-map-overrides)
|
||||||
|
(when ebox--saved-overline-margin
|
||||||
|
(if (car ebox--saved-overline-margin)
|
||||||
|
(setq-local overline-margin (cdr ebox--saved-overline-margin))
|
||||||
|
(kill-local-variable 'overline-margin))
|
||||||
|
(setq ebox--saved-overline-margin nil))))
|
||||||
|
|
||||||
(defun ebox--render-observer-option (options)
|
(defun ebox--render-observer-option (options)
|
||||||
"Validate OPTIONS and return `(PRESENT . OBSERVER)'."
|
"Validate OPTIONS and return `(PRESENT . OBSERVER)'."
|
||||||
|
|||||||
@ -5,6 +5,37 @@
|
|||||||
(require 'ert)
|
(require 'ert)
|
||||||
(require 'ebox)
|
(require 'ebox)
|
||||||
|
|
||||||
|
(ert-deftest ebox-display-border-metrics-restore-on-unmount ()
|
||||||
|
"Mounted borders keep the line grid without leaking redisplay settings."
|
||||||
|
(let ((default-margin (default-value 'overline-margin)))
|
||||||
|
(dolist (local-margin '(nil 7))
|
||||||
|
(with-temp-buffer
|
||||||
|
(when local-margin (setq-local overline-margin local-margin))
|
||||||
|
(let ((input (ebox-build '(box :border "red" "Border"))))
|
||||||
|
(ebox-render-to-buffer (current-buffer) input)
|
||||||
|
(should (local-variable-p 'overline-margin))
|
||||||
|
(should (zerop overline-margin))
|
||||||
|
;; Remounting must not replace the original setting with zero.
|
||||||
|
(ebox-render-to-buffer (current-buffer) input)
|
||||||
|
(should (zerop overline-margin))
|
||||||
|
(ebox-unmount-buffer (current-buffer))
|
||||||
|
(should (eq (local-variable-p 'overline-margin) (and local-margin t)))
|
||||||
|
(should (= overline-margin (or local-margin default-margin))))))
|
||||||
|
(should (= (default-value 'overline-margin) default-margin))))
|
||||||
|
|
||||||
|
(ert-deftest ebox-display-failed-mount-preserves-border-metrics ()
|
||||||
|
"An unsuccessful initial publication must leave native metrics alone."
|
||||||
|
(with-temp-buffer
|
||||||
|
(setq-local overline-margin 7)
|
||||||
|
(let ((tp--surface-publication-step-function
|
||||||
|
(lambda (step _surface)
|
||||||
|
(when (eq step 'client-state) (error "Reject initial mount")))))
|
||||||
|
(should-error
|
||||||
|
(ebox-render-to-buffer (current-buffer)
|
||||||
|
(ebox-build '(box :border "red" "Border")))))
|
||||||
|
(should (= overline-margin 7))
|
||||||
|
(should-not ebox-buffer-mode)))
|
||||||
|
|
||||||
(ert-deftest ebox-display-invalid-input-preserves-windows ()
|
(ert-deftest ebox-display-invalid-input-preserves-windows ()
|
||||||
"Invalid input must fail before changing the caller's window layout."
|
"Invalid input must fail before changing the caller's window layout."
|
||||||
(save-window-excursion
|
(save-window-excursion
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user