Skip to content

Bundled Svelte grammar has cyclical includes — syntect consumers spin forever #4081

Closed

Description

@yxxbc

Title: Bundled Svelte grammar has cyclical includes — syntect consumers spin forever

The Svelte syntax this crate bundles (02_Extra/Svelte, the
corneliusio/svelte-sublime submodule) contains cyclical includes:

style-common  → style-lang-attribute → style-lang-decider-type → style-common
style-common  → style-lang-attribute → style-lang-decider-lang → style-common
script-common → script-lang-attribute → script-lang-decider-lang → script-common
style-lang-decider-type → script-common → script-lang-attribute → …

Sublime Text / VS Code tolerate these (their include walk is cycle-safe), but
syntect's is not: MatchIter::next pushes the target context with no
"already on the stack?" check, so the context stack grows without bound and
parse_line never returns.

Concretely: highlighting a five-byte line — /** — inside a Svelte diff
pins a core at 100 % forever. html / javascript / typescript / vue parse
the same input in < 10 ms; only svelte loops. It is neither line length nor
regex backtracking (capping oniguruma's retry_limit_in_match to 20 000 still
spins).

This is filed here (rather than only upstream) because two-face ships the
grammar, so every two-face user who highlights a Svelte file hits it. A
second, non-consuming-set loop in parse_line compounds it.

Happy to send a PR here too if you'd rather adjust the bundled grammar (or pin
a fixed syntect) — just say which you prefer.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions