Skip to content

Commit e7013e6

Browse files
committed
Fixed search crashing for some nested heading combinations (9.0.3 regression)
1 parent c31ef00 commit e7013e6

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

material/plugins/search/plugin.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -421,11 +421,11 @@ def handle_endtag(self, tag):
421421
# which could also be a nested section – see https://bit.ly/3IxxIJZ
422422
if self.section.depth > len(self.context):
423423
for section in reversed(self.data):
424-
if section.depth and section.depth <= len(self.context):
424+
if section.depth <= len(self.context):
425425

426-
# Set depth to 0 in order to denote that the current section
427-
# is exited and must not be considered again.
428-
self.section.depth = 0
426+
# Set depth to infinity in order to denote that the current
427+
# section is exited and must never be considered again.
428+
self.section.depth = float("inf")
429429
self.section = section
430430
break
431431

src/plugins/search/plugin.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -421,11 +421,11 @@ def handle_endtag(self, tag):
421421
# which could also be a nested section – see https://bit.ly/3IxxIJZ
422422
if self.section.depth > len(self.context):
423423
for section in reversed(self.data):
424-
if section.depth and section.depth <= len(self.context):
424+
if section.depth <= len(self.context):
425425

426-
# Set depth to 0 in order to denote that the current section
427-
# is exited and must not be considered again.
428-
self.section.depth = 0
426+
# Set depth to infinity in order to denote that the current
427+
# section is exited and must never be considered again.
428+
self.section.depth = float("inf")
429429
self.section = section
430430
break
431431

0 commit comments

Comments
 (0)