aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-27 20:48:12 -0500
committerCraig Jennings <c@cjennings.net>2026-05-27 20:48:12 -0500
commit7833fb8bc0e3f9ece01ab2fe6fe07ded0efc4af4 (patch)
tree28234f51c546258fa57d40fe02bf0d30280182f1 /tests
parent822e7a3798d431910eeff677ae751eff8b48731a (diff)
downloaddotemacs-7833fb8bc0e3f9ece01ab2fe6fe07ded0efc4af4.tar.gz
dotemacs-7833fb8bc0e3f9ece01ab2fe6fe07ded0efc4af4.zip
fix(vterm): never reopen the F9/F12 windows from the top
F9 brought the agent window down from the top of the frame. The toggle remembers where the window last sat and replays it, and "above" was a position it could capture and replay: move the window to the top with the buffer-move keys, toggle off, and the next toggle reopened it up there. The host default never picks the top, so a remembered "above" was the only way in. I added an optional allowed-directions list to cj/window-toggle-capture-state, the helper both F9 (ai-vterm) and F12 (vterm-config) share. When the captured direction isn't in the list, it falls back to the default direction and clears the saved size, since that size was measured on the disallowed axis and wouldn't transfer. Both dispatchers now pass (right below left), so neither can remember a top placement. They go through the same helper, so the rule stays in one place. Three tests cover the new branch: a permitted direction is kept, a disallowed one falls back with the size cleared, and an omitted list preserves the old unconstrained behavior so existing callers are unaffected.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-cj-window-toggle-lib.el46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/test-cj-window-toggle-lib.el b/tests/test-cj-window-toggle-lib.el
index ca4b7fef..0762e255 100644
--- a/tests/test-cj-window-toggle-lib.el
+++ b/tests/test-cj-window-toggle-lib.el
@@ -91,6 +91,52 @@
(should (eq test-cj-window-toggle--last-direction 'sentinel-dir))
(should (= test-cj-window-toggle--last-size 0.123))))
+(ert-deftest test-cj-window-toggle-capture-allowed-keeps-permitted-direction ()
+ "Normal: a captured direction in ALLOWED is stored with its body size."
+ (save-window-excursion
+ (delete-other-windows)
+ (let ((below (split-window (selected-window) nil 'below))
+ (test-cj-window-toggle--last-direction nil)
+ (test-cj-window-toggle--last-size nil))
+ (cj/window-toggle-capture-state
+ below 'below
+ 'test-cj-window-toggle--last-direction
+ 'test-cj-window-toggle--last-size
+ '(right below left))
+ (should (eq test-cj-window-toggle--last-direction 'below))
+ (should (integerp test-cj-window-toggle--last-size)))))
+
+(ert-deftest test-cj-window-toggle-capture-allowed-rejects-disallowed-direction ()
+ "Boundary: a direction not in ALLOWED falls back to default, size cleared.
+The captured body size was measured on the disallowed axis, so it can't
+transfer; clearing it lets the consumer's default size apply."
+ (save-window-excursion
+ (delete-other-windows)
+ (let ((above (split-window (selected-window) nil 'above))
+ (test-cj-window-toggle--last-direction 'sentinel)
+ (test-cj-window-toggle--last-size 99))
+ (cj/window-toggle-capture-state
+ above 'below
+ 'test-cj-window-toggle--last-direction
+ 'test-cj-window-toggle--last-size
+ '(right below left))
+ (should (eq test-cj-window-toggle--last-direction 'below))
+ (should (null test-cj-window-toggle--last-size)))))
+
+(ert-deftest test-cj-window-toggle-capture-allowed-nil-keeps-all ()
+ "Boundary: omitting ALLOWED preserves the prior unconstrained behavior."
+ (save-window-excursion
+ (delete-other-windows)
+ (let ((above (split-window (selected-window) nil 'above))
+ (test-cj-window-toggle--last-direction nil)
+ (test-cj-window-toggle--last-size nil))
+ (cj/window-toggle-capture-state
+ above 'below
+ 'test-cj-window-toggle--last-direction
+ 'test-cj-window-toggle--last-size)
+ (should (eq test-cj-window-toggle--last-direction 'above))
+ (should (integerp test-cj-window-toggle--last-size)))))
+
(ert-deftest test-cj-window-toggle-display-saved-uses-defaults-when-state-nil ()
"Normal: nil state -> direction=edge of default, size=default."
(let (received-alist