From 97aa84a438260bbde70623244d89aaf9013936e1 Mon Sep 17 00:00:00 2001 From: Johan Walles Date: Tue, 7 Mar 2023 20:51:54 +0100 Subject: [PATCH 1/7] Test removing trailing newline With highlighting using a suitable Unicode character. --- testdata/remove-trailing-newline.riff-output | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdata/remove-trailing-newline.riff-output b/testdata/remove-trailing-newline.riff-output index 36d5fd1..783740e 100644 --- a/testdata/remove-trailing-newline.riff-output +++ b/testdata/remove-trailing-newline.riff-output @@ -1,3 +1,3 @@ --apor +-apor⏎ +apor \ No newline at end of file From 2621e42098fc472331ced1d61f1a34ecd658d3fb Mon Sep 17 00:00:00 2001 From: Johan Walles Date: Tue, 7 Mar 2023 21:02:47 +0100 Subject: [PATCH 2/7] Test adding a missing trailing newline --- testdata/add-trailing-newline.diff | 3 +++ testdata/add-trailing-newline.riff-output | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 testdata/add-trailing-newline.diff create mode 100644 testdata/add-trailing-newline.riff-output diff --git a/testdata/add-trailing-newline.diff b/testdata/add-trailing-newline.diff new file mode 100644 index 0000000..a5d2615 --- /dev/null +++ b/testdata/add-trailing-newline.diff @@ -0,0 +1,3 @@ +-apor +\ No newline at end of file ++apor \ No newline at end of file diff --git a/testdata/add-trailing-newline.riff-output b/testdata/add-trailing-newline.riff-output new file mode 100644 index 0000000..1f0b0c0 --- /dev/null +++ b/testdata/add-trailing-newline.riff-output @@ -0,0 +1,3 @@ +-apor +\ No newline at end of file ++apor⏎ From adc37fd0f770a28069f77b9c8693406e0db5c281 Mon Sep 17 00:00:00 2001 From: Johan Walles Date: Wed, 8 Mar 2023 06:58:55 +0100 Subject: [PATCH 3/7] Add no-EOL-to-no-EOL test case Unsure how we should render this. --- testdata/changed-lines-without-newlines.diff | 4 ++++ testdata/changed-lines-without-newlines.riff-output | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 testdata/changed-lines-without-newlines.diff create mode 100644 testdata/changed-lines-without-newlines.riff-output diff --git a/testdata/changed-lines-without-newlines.diff b/testdata/changed-lines-without-newlines.diff new file mode 100644 index 0000000..450fba9 --- /dev/null +++ b/testdata/changed-lines-without-newlines.diff @@ -0,0 +1,4 @@ +-apor +\ No newline at end of file ++aporna +\ No newline at end of file \ No newline at end of file diff --git a/testdata/changed-lines-without-newlines.riff-output b/testdata/changed-lines-without-newlines.riff-output new file mode 100644 index 0000000..eab9a9f --- /dev/null +++ b/testdata/changed-lines-without-newlines.riff-output @@ -0,0 +1,4 @@ +-apor +\ No newline at end of file ++aporna +\ No newline at end of file From 9fb6b13f013b8de4098fea14dddd4a32b2e17e28 Mon Sep 17 00:00:00 2001 From: Johan Walles Date: Wed, 8 Mar 2023 07:04:35 +0100 Subject: [PATCH 4/7] This is how we should highlight it --- testdata/changed-lines-without-newlines.riff-output | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testdata/changed-lines-without-newlines.riff-output b/testdata/changed-lines-without-newlines.riff-output index eab9a9f..7d76ee1 100644 --- a/testdata/changed-lines-without-newlines.riff-output +++ b/testdata/changed-lines-without-newlines.riff-output @@ -1,4 +1,4 @@ --apor +-apor \ No newline at end of file -+aporna ++aporna \ No newline at end of file From e67b812856a0e7eef957f3b6b4c1ef9a612e51be Mon Sep 17 00:00:00 2001 From: Johan Walles Date: Wed, 8 Mar 2023 08:21:22 +0100 Subject: [PATCH 5/7] Expect no highlight for fully changed lines --- testdata/changed-lines-without-newlines.riff-output | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testdata/changed-lines-without-newlines.riff-output b/testdata/changed-lines-without-newlines.riff-output index 7d76ee1..eab9a9f 100644 --- a/testdata/changed-lines-without-newlines.riff-output +++ b/testdata/changed-lines-without-newlines.riff-output @@ -1,4 +1,4 @@ --apor +-apor \ No newline at end of file -+aporna ++aporna \ No newline at end of file From 463483457770ee105b0338cb6baf7716345c47ff Mon Sep 17 00:00:00 2001 From: Johan Walles Date: Wed, 8 Mar 2023 08:24:56 +0100 Subject: [PATCH 6/7] =?UTF-8?q?TODO:=20Use=20=E2=90=9B=20for=20escape=20ch?= =?UTF-8?q?aracters=20in=20the=20diff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0ea82e1..c89beb5 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ If you want to test the release script without actually releasing anything, do: ## Misc +- Render ESC characters in the diff as Unicode ␛ - `--help`: Only print installing-into-`$PATH` help if we aren't already being executed from inside of the `$PATH` - Do `git show 5e0a1b2b13528f40299e78e3bfa590d9f96637af` and scroll to the end. From 8beb845f550c58bdd39931d759cfc8d78f20b90d Mon Sep 17 00:00:00 2001 From: Johan Walles Date: Thu, 9 Mar 2023 06:46:40 +0100 Subject: [PATCH 7/7] Make the tests pass --- src/refiner.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/refiner.rs b/src/refiner.rs index 1aa88a4..344cca6 100644 --- a/src/refiner.rs +++ b/src/refiner.rs @@ -105,8 +105,15 @@ fn format_split(old_text: &str, new_text: &str) -> Option<(Vec, Vec