Skip to content

Commit a756764

Browse files
committed
fix(sidebar): remove ignored headings and children
1 parent c9301b0 commit a756764

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/core/render/compiler.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,10 @@ export class Compiler {
200200
if (toc[i].ignoreSubHeading) {
201201
const deletedHeaderLevel = toc[i].depth;
202202
toc.splice(i, 1);
203-
// Remove headers who are under current header
204-
for (
205-
let j = i;
206-
j < toc.length && deletedHeaderLevel < toc[j].depth;
207-
j++
208-
) {
209-
toc.splice(j, 1) && j-- && i++;
203+
204+
// Remove all following headings with greater depth
205+
while (i < toc.length && toc[i].depth > deletedHeaderLevel) {
206+
toc.splice(i, 1);
210207
}
211208

212209
i--;

0 commit comments

Comments
 (0)