From c51f8af6abc4aef79515bf2092d925eb551af255 Mon Sep 17 00:00:00 2001 From: "kiber.io" <60169133+kiber-io@users.noreply.github.com> Date: Tue, 24 Jun 2025 20:41:21 +0400 Subject: [PATCH 1/2] fix: ensure newline before moving checkbox to end of block --- main.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.ts b/main.ts index 97cb705..a28bf77 100644 --- a/main.ts +++ b/main.ts @@ -281,6 +281,14 @@ export default class ObsidianCheckboxSort extends Plugin { if (isPeerTickedForSorting) { tickedItemsData.push(itemData); } else { + // If this is the last item, it doesn't have a newline, and the first moved checkbox also doesn't have a newline - add a newline to this line. + if ( + i == blockEndLine && + tickedItemsData.length > 0 && + !tickedItemsData[0].text.startsWith("\n") + ) { + itemData.text += "\n"; + } untickedItemsData.push(itemData); } From 03d1dd110ee14aadd7a0f9288ec2a781fef2d6bb Mon Sep 17 00:00:00 2001 From: "kiber.io" <60169133+kiber-io@users.noreply.github.com> Date: Tue, 24 Jun 2025 20:49:17 +0400 Subject: [PATCH 2/2] don't add newline if current line already has it --- main.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/main.ts b/main.ts index a28bf77..e803975 100644 --- a/main.ts +++ b/main.ts @@ -284,6 +284,7 @@ export default class ObsidianCheckboxSort extends Plugin { // If this is the last item, it doesn't have a newline, and the first moved checkbox also doesn't have a newline - add a newline to this line. if ( i == blockEndLine && + !itemData.text.endsWith("\n") && tickedItemsData.length > 0 && !tickedItemsData[0].text.startsWith("\n") ) {