Himujjal / tree-sitter-svelte

Tree sitter grammar for Svelte
MIT License
83 stars 14 forks source link

expressions containing newlines breaks #61

Open AlbertMarashi opened 2 months ago

AlbertMarashi commented 2 months ago

PR #50 broke something which was merged into zed and is now affecting my code.

Test case:

<script>
let foo = {
    bar: "baz"
}
</script>
<foo
    baz={{

    }}>

    {#if foo.bar}
        { foo.bar }
    {/if}
</foo>
<style>
foo {
    display: flex;
    flex-direction: column;
}
</style>

image

For some reason, newlines within the baz prop appear to break parsing

If I remove the newlines, it parses

image

Downgrading the zed extension's commit version to #49's fixes the bug, so something in here seems like it was introduced which broke parsing.

AlbertMarashi commented 2 months ago

Simpler test case:

Works:

{{ "foo": "bar" }}

Breaks

{{
   "foo": "bar"
}}
AlbertMarashi commented 2 months ago

I believe a bunch of faulty logic was added inside of: https://github.com/Himujjal/tree-sitter-svelte/blob/master/src/scanner.c#L270-L273

I placed some review comments on the commit