aboutsummaryrefslogtreecommitdiff
path: root/tests/test-ai-vterm--window-geometry.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-09 11:03:10 -0500
committerCraig Jennings <c@cjennings.net>2026-05-09 11:03:10 -0500
commit26e97633c2141051dee418aff5d8993700cf39b2 (patch)
tree7dbe6fa685c0b3093f6e7952a340bb61e44ccbea /tests/test-ai-vterm--window-geometry.el
parent1945df4bf5f34256908fdf221da8a6f7767ad427 (diff)
downloaddotemacs-26e97633c2141051dee418aff5d8993700cf39b2.tar.gz
dotemacs-26e97633c2141051dee418aff5d8993700cf39b2.zip
fix(ai-vterm): harden F9 toggle across multi-window and buffer-move
Live-testing surfaced four edge-case failures in the F9 toggle geometry preservation. Each gets a dedicated regression test. - Multi-window squeeze: a captured fraction-of-frame replayed at the wrong size in 3+ window layouts because `display-buffer-in-direction` interprets float widths as fractions of the new window's parent, not the frame. In a flat 3-window layout the parent is the root, but in nested splits it's a sub-tree, and the captured fraction blew the layout up. I switched to absolute integer body-cols and body-lines as the captured unit. The unit is layout-independent. - One-col peek: a claude window captured rightmost (no right divider, body=total) replayed into a middle position (with divider, body=total-1) showed 1 col of the sibling buffer peeking through where claude should have ended. I wrap the integer size in a `(body-columns . N)` / `(body-lines . N)` cons so `display-buffer-in-direction` sets the body explicitly, divider-independent. - Position swap and compounding gap: `direction=right` in `display-buffer-in-direction` splits the selected window, not the frame edge. In multi-window layouts the new claude landed mid-frame instead of where it came from. Each toggle compounded a 1-col loss because the new position picked up a divider the original lacked. I map the cardinal direction to its frame-edge variant (`right` -> `rightmost`, `below` -> `bottom`, etc.) so claude always returns to the captured edge. - Extra window after buffer-move: buffer-move (C-M-arrows) doesn't update the claude window's `quit-restore` parameter, so `quit-window` falls through to bury rather than delete. The window stays alive showing some other buffer. Toggle-on doesn't recognize it and creates a fresh side window, landing at N+1 windows. I switched to `delete-window` with a `one-window-p` guard for the single-window-frame case. One tradeoff: in a layout where claude was deliberately in a middle position (e.g. agenda | claude | todo), the next toggle pulls it to the frame edge rather than the middle. The side-panel pattern is the design intent and the common case. 7 new regression tests covering each scenario. 80 ai-vterm tests pass. Full make test green.
Diffstat (limited to 'tests/test-ai-vterm--window-geometry.el')
-rw-r--r--tests/test-ai-vterm--window-geometry.el27
1 files changed, 15 insertions, 12 deletions
diff --git a/tests/test-ai-vterm--window-geometry.el b/tests/test-ai-vterm--window-geometry.el
index 62b78baf8..c22002739 100644
--- a/tests/test-ai-vterm--window-geometry.el
+++ b/tests/test-ai-vterm--window-geometry.el
@@ -55,31 +55,34 @@
(delete-other-windows)
(should (eq (cj/--ai-vterm-window-direction (selected-window)) 'right))))
-(ert-deftest test-ai-vterm--window-fraction-right-split-half ()
- "Normal: right window of equal vertical split -> ~0.5 width fraction."
+(ert-deftest test-ai-vterm--window-size-right-split-returns-body-cols ()
+ "Normal: right window -> integer body-cols matching window-body-width."
(save-window-excursion
(delete-other-windows)
(let* ((right (split-window (selected-window) nil 'right))
- (frac (cj/--ai-vterm-window-fraction right 'right)))
- (should (and (> frac 0.4) (< frac 0.6))))))
+ (size (cj/--ai-vterm-window-size right 'right)))
+ (should (integerp size))
+ (should (= size (window-body-width right))))))
-(ert-deftest test-ai-vterm--window-fraction-below-split-half ()
- "Normal: bottom window of equal horizontal split -> ~0.5 height fraction."
+(ert-deftest test-ai-vterm--window-size-below-split-returns-body-lines ()
+ "Normal: bottom window -> integer body-lines matching window-body-height."
(save-window-excursion
(delete-other-windows)
(let* ((below (split-window (selected-window) nil 'below))
- (frac (cj/--ai-vterm-window-fraction below 'below)))
- (should (and (> frac 0.4) (< frac 0.6))))))
+ (size (cj/--ai-vterm-window-size below 'below)))
+ (should (integerp size))
+ (should (= size (window-body-height below))))))
-(ert-deftest test-ai-vterm--window-fraction-narrow-right-split ()
- "Normal: right window at 1/4 width -> fraction within that range."
+(ert-deftest test-ai-vterm--window-size-narrow-right-split ()
+ "Normal: deliberately narrow right window -> matching body-col count."
(save-window-excursion
(delete-other-windows)
(let* ((frame-w (frame-width))
(target-cols (/ frame-w 4))
(right (split-window (selected-window) (- target-cols) 'right))
- (frac (cj/--ai-vterm-window-fraction right 'right)))
- (should (and (> frac 0.15) (< frac 0.35))))))
+ (size (cj/--ai-vterm-window-size right 'right)))
+ (should (integerp size))
+ (should (= size (window-body-width right))))))
(provide 'test-ai-vterm--window-geometry)
;;; test-ai-vterm--window-geometry.el ends here