From 15a4c19fc24a4422122844e20be7ab569d676865 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 11 Jul 2026 14:18:02 -0500 Subject: fix(custom-comments): correct comment-reformat and inline-border cj/comment-reformat printed "No region was selected" on every call, even successful ones, because the message sat outside the if. Its fill-column shrink used a raw setq and restore, so an error mid-join left fill-column permanently at -3. It now signals a user-error when there's no region and dynamically binds fill-column, which restores itself. cj/--comment-inline-border sized the right decoration from text-length parity, leaving even-length and empty text two columns short and misaligning stacked dividers. It now fills the exact remaining width. Both fixes ship with tests, and the inline-border test asserts exact width across parities. --- tests/test-custom-comments-comment-inline-border.el | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/test-custom-comments-comment-inline-border.el') diff --git a/tests/test-custom-comments-comment-inline-border.el b/tests/test-custom-comments-comment-inline-border.el index 78e86035..305a2c7a 100644 --- a/tests/test-custom-comments-comment-inline-border.el +++ b/tests/test-custom-comments-comment-inline-border.el @@ -120,6 +120,16 @@ Returns the buffer string for assertions." (let ((result (test-inline-border-at-column 0 ";;" "" "=" "" 10))) (should (string-match-p ";" result)))) +(ert-deftest test-inline-border-elisp-fills-exact-width-all-parities () + "Boundary: even, odd, and empty text all fill LENGTH exactly. +Even-length and empty text used to come out two columns short because the +right decoration count keyed off text-length parity instead of the remaining +width, so stacked dividers of differing text lengths misaligned." + (dolist (text '("" "X" "EVEN" "ODD" "Header")) + (let* ((result (test-inline-border-at-column 0 ";;" "" "=" text 50)) + (line (string-trim-right result "\n"))) + (should (= 50 (length line)))))) + (ert-deftest test-inline-border-elisp-text-centering-even () "Should center text properly with even length." (let ((result (test-inline-border-at-column 0 ";;" "" "=" "EVEN" 70))) -- cgit v1.2.3