Merge pull request #1 from kiber-io/master

Fix checkbox merge issue when last item lacks newline
This commit is contained in:
Matt Tang 2025-06-24 19:54:49 -07:00 committed by GitHub
commit d28c3704c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -281,6 +281,15 @@ 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 &&
!itemData.text.endsWith("\n") &&
tickedItemsData.length > 0 &&
!tickedItemsData[0].text.startsWith("\n")
) {
itemData.text += "\n";
}
untickedItemsData.push(itemData);
}