From f837e5f7464932fc49c10a7442dc1a23af61b257 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 11 May 2026 15:16:56 -0500 Subject: feat(window): resize the split with C-; b `C-; b ///' moves the active window's divider that way (via `windsize'), then keeps `cj/window-resize-map' active so bare arrows keep nudging until any other key (or `C-g'/`'). `C-u N C-; b ' resizes by N. windsize was on `C-s-' (Ctrl+Super), which a tiling WM intercepts, so those keys were useless. I dropped that binding. The package is now `:commands'-deferred, and `windsize-cols'/`windsize-rows' drop to 2 (8/4 overshoots in a held nudge loop). `cj/window-resize-sticky' dispatches on the arrow that triggered it and arms the loop. --- tests/test-ui-navigation--window-resize.el | 51 ++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tests/test-ui-navigation--window-resize.el (limited to 'tests') diff --git a/tests/test-ui-navigation--window-resize.el b/tests/test-ui-navigation--window-resize.el new file mode 100644 index 00000000..3be0313b --- /dev/null +++ b/tests/test-ui-navigation--window-resize.el @@ -0,0 +1,51 @@ +;;; test-ui-navigation--window-resize.el --- Tests for the C-; b resize keys -*- lexical-binding: t; -*- + +;;; Commentary: +;; `C-; b ///' moves the active window's divider in the +;; arrow's direction (via `windsize'), then keeps `cj/window-resize-map' active +;; so bare arrows keep nudging until any other key. We own the dispatch +;; (`cj/window-resize-sticky' -- pick the matching `windsize-*' command, run it, +;; arm the loop) and the keymaps; the resize math is `windsize's job and isn't +;; tested here. + +;;; Code: + +(require 'ert) +(require 'cl-lib) + +(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) +(require 'ui-navigation) + +(ert-deftest test-ui-navigation-window-resize-map-bindings () + "Normal: the sticky-resize map maps the four arrows to the `windsize' commands." + (should (eq (keymap-lookup cj/window-resize-map "") #'windsize-left)) + (should (eq (keymap-lookup cj/window-resize-map "") #'windsize-right)) + (should (eq (keymap-lookup cj/window-resize-map "") #'windsize-up)) + (should (eq (keymap-lookup cj/window-resize-map "") #'windsize-down))) + +(ert-deftest test-ui-navigation-window-resize-sticky-dispatches-and-arms () + "Normal: `cj/window-resize-sticky' runs the `windsize' command matching the +arrow key that triggered it, then arms the sticky-repeat map." + (dolist (case '((left . windsize-left) + (right . windsize-right) + (up . windsize-up) + (down . windsize-down))) + (let ((ran nil) + (overriding-terminal-local-map nil) + (pre-command-hook nil)) + (cl-letf (((symbol-function (cdr case)) + (lambda (&rest _) (interactive) (setq ran t)))) + (let ((last-command-event (car case))) + (cj/window-resize-sticky))) + (should ran) ; dispatched to the right command + (should overriding-terminal-local-map)))) ; loop armed + +(ert-deftest test-ui-navigation-window-resize-bound-under-c-semicolon-b () + "Normal: `C-; b ' (each direction) reaches the sticky-resize command." + (require 'custom-buffer-file) + (dolist (arrow '("" "" "" "")) + (should (eq (keymap-lookup cj/buffer-and-file-map arrow) + #'cj/window-resize-sticky)))) + +(provide 'test-ui-navigation--window-resize) +;;; test-ui-navigation--window-resize.el ends here -- cgit v1.2.3