Skip to content

Commit c2ccf93

Browse files
committed
fix: Correct nested headings when multiple groups are used.
In afcb2fe I moved the sorting of groups to a different location, and didn't spot the change in behaviour, because I was now sorting the groups after the display headings had been calculated, meaning that in some cases the wrong headings were displayed. Now, the groups are sorted before calculating which headings to display.
1 parent 92a0df4 commit c2ccf93

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Query/TaskGroups.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ export class TaskGroups {
7878
this.add(taskGroup);
7979
}
8080

81-
// Get the headings.
81+
this.sortTaskGroups();
82+
83+
// Get the headings, now that the groups have been sorted.
8284
const displayHeadingSelector = new GroupDisplayHeadingSelector(taskGroupingTree.groups);
8385
for (const group of this._groups) {
8486
group.setGroupHeadings(displayHeadingSelector.getHeadingsForTaskGroup(group.groups));
8587
}
86-
87-
this.sortTaskGroups();
8888
}
8989

9090
private add(taskGroup: TaskGroup) {

tests/TaskGroups.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ describe('Grouping tasks', () => {
269269
expect(groups.toString()).toMatchInlineSnapshot(`
270270
"
271271
Group names: [2 TODO,2022-09-19 Monday]
272+
#### 2 TODO
272273
##### 2022-09-19 Monday
273274
- [ ] Task a - early date 📅 2022-09-19
274275
@@ -281,7 +282,6 @@ describe('Grouping tasks', () => {
281282
---
282283
283284
Group names: [2 TODO,2022-12-06 Tuesday]
284-
#### 2 TODO
285285
##### 2022-12-06 Tuesday
286286
- [ ] Task b - later date ⏳ 2022-12-06
287287

0 commit comments

Comments
 (0)