Skip to content

Commit

Permalink
fix: fix duplicate for subsection
Browse files Browse the repository at this point in the history
  • Loading branch information
OrangeX4 committed Apr 6, 2024
1 parent 31e2be2 commit 9e580b4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion utils/states.typ
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@
#let _new-subsection(short-title: auto, duplicate: false, title) = locate(loc => {
sections-state.update(sections => {
let last-section = sections.pop()
let last-subsection = last-section.children.at(-1, default: (kind: "subsection", title: none, short-title: none, loc: none, count: 0, children: ()))
let last-subsection = (kind: "none")
let i = -1
while last-subsection.kind != "subsection" {
last-subsection = last-section.children.at(i, default: (kind: "subsection", title: none, short-title: none, loc: none, count: 0, children: ()))
i += 1
}
if duplicate or last-subsection.title != title or last-subsection.short-title != short-title {
last-section.children.push((kind: "subsection", title: title, short-title: short-title, loc: loc, count: 0, children: ()))
}
Expand Down

0 comments on commit 9e580b4

Please sign in to comment.