Skip to content

Commit 198bbb4

Browse files
authored
Merge branch 'FossifyOrg:main' into DialogView-StatePreservation
2 parents 22113b0 + c0f134c commit 198bbb4

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Fixed
10+
- Fixed inconsistent checklist sorting when the "Move checked items to the bottom" option is enabled ([#59])
11+
912
## [1.6.0] - 2025-10-29
1013
### Changed
1114
- Compatibility updates for Android 15 & 16
@@ -91,6 +94,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9194
### Added
9295
- Initial release
9396

97+
[#59]: https://github.com/FossifyOrg/Notes/issues/59
9498
[#81]: https://github.com/FossifyOrg/Notes/issues/81
9599
[#83]: https://github.com/FossifyOrg/Notes/issues/83
96100
[#99]: https://github.com/FossifyOrg/Notes/issues/99

app/src/main/kotlin/org/fossify/notes/fragments/TasksFragment.kt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,13 +312,28 @@ class TasksFragment : NoteFragment(), TasksActionListener {
312312

313313
override fun moveTask(fromPosition: Int, toPosition: Int) {
314314
switchToCustomSorting()
315+
316+
val sortableIndices = mutableListOf<Int>()
317+
val checkedCanBeMoved = config?.moveDoneChecklistItems == false
318+
for (i in 0 until tasks.size) {
319+
if (checkedCanBeMoved || !tasks[i].isDone) {
320+
sortableIndices.add(i)
321+
}
322+
}
323+
315324
if (fromPosition < toPosition) {
316325
for (i in fromPosition until toPosition) {
317-
tasks.swap(i, i + 1)
326+
val toMoveIndex = sortableIndices[i]
327+
if (i + 1 < sortableIndices.size) {
328+
val headingIndex = sortableIndices[i + 1]
329+
tasks.swap(toMoveIndex, headingIndex)
330+
}
318331
}
319332
} else {
320333
for (i in fromPosition downTo toPosition + 1) {
321-
tasks.swap(i, i - 1)
334+
val toMoveIndex = sortableIndices[i]
335+
val headingIndex = sortableIndices[i - 1]
336+
tasks.swap(toMoveIndex, headingIndex)
322337
}
323338
}
324339

0 commit comments

Comments
 (0)