uben0 / tree-sitter-typst

Tree Sitter grammar for Typst
MIT License
114 stars 10 forks source link

Unreachable when writing a square bracket and a list #18

Closed monaqa closed 9 months ago

monaqa commented 9 months ago

In text mode, if a list is written after a square bracket without escaping, an unreachable error is displayed during parsing. The list does not have to be immediately after the square bracket, and it seems to reproduce even when placed across paragraphs and apart.


Since installing tree-sitter-typst, my Typst environment has become much more comfortable. Thank you so much!

uben0 commented 9 months ago

I found the bug and fixed it.

Explanation:

Plain text square brackets, as they have an effect on the semantic:

#strong[Hello [] World]
#strong[Hello  ] World]

They are considered as containers, and as they do not effect the indentation, no indentation level is pushed on the indentation stack. But when the ] was encountered, the indentation stack was pop of one level. I removed this pop.

monaqa commented 9 months ago

I tried ecf8596 it in my environment and confirmed that the problem has been resolved. Thank you for your quick response and fix!