From 016f322de184b09d79cb1d7db522a0aaa6c00a9f Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 11 Jul 2026 14:29:03 -0500 Subject: fix(custom-ordering): preserve the trailing newline in reverse and number cj/reverse-lines and cj/number-lines split the region on newlines without accounting for a trailing one, so it became a spurious empty element. Reversing "a\nb\n" floated that empty to the top ("\nb\na"), and numbering added a phantom final numbered line. Both now strip a trailing newline before splitting and reattach it after, matching cj/--arrayify, while preserving internal blank lines. Corrected the two tests that asserted the broken output. --- tests/test-custom-ordering-number-lines.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/test-custom-ordering-number-lines.el') diff --git a/tests/test-custom-ordering-number-lines.el b/tests/test-custom-ordering-number-lines.el index adda84f0..142e5561 100644 --- a/tests/test-custom-ordering-number-lines.el +++ b/tests/test-custom-ordering-number-lines.el @@ -122,9 +122,10 @@ Returns the transformed string." (should (string= result "1. ")))) (ert-deftest test-number-lines-empty-lines () - "Should number empty lines." + "Should number empty lines, treating the final newline as a terminator. +The old split counted the trailing newline as a spurious third line." (let ((result (test-number-lines "\n\n" "N. " nil))) - (should (string= result "1. \n2. \n3. ")))) + (should (string= result "1. \n2. \n")))) (ert-deftest test-number-lines-with-existing-numbers () "Should number lines that already have content." -- cgit v1.2.3