Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vsc collapse/folding gets confused if < is used in condition #2537

Open
Ray57 opened this issue Oct 16, 2024 · 3 comments
Open

vsc collapse/folding gets confused if < is used in condition #2537

Ray57 opened this issue Oct 16, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@Ray57
Copy link

Ray57 commented Oct 16, 2024

Describe the bug

If "less than" is used in a svelte conditional statement and the block contains a wrapping

, vsc does not display the "v" to allow collapse of the block. Use of anything else works. E.G. {#if step > 1} {#if step == 1}

Reproduction

{#if step < 1}
    <div>
        Not collapsible (Neither <!-- {#if} nor <div> -->)
    </div>
{/if}

Expected behaviour

{#if step < 1}
    Collapsible (No <div> present)
{/if}

{#if step > 1}
    <div>
        Collapsible (Both <!-- {#if} and <div> -->)
    </div>
{/if}

System Info

Windows
VSCode

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

Issue - Collapse

@Ray57 Ray57 added the bug Something isn't working label Oct 16, 2024
@jasonlyu123
Copy link
Member

Can you provide an example of the nested if block issue? The problem with div is because of how vscode-html-languageservice parses the file but that shouldn't affect if-block folding.

@Ray57
Copy link
Author

Ray57 commented Oct 20, 2024

I did some more testing to isolate the behavior. The .txt is a .svelte file. I took a screenshot with the cursor over the left column to display all of the "v" folds. The first just shows that an empty div doesn't fold which makes sense. The next adds content and the divs become foldable. Next, I change the > into a <. This demonstrates the root issue. The first div after the use of < is no longer foldable. Now I do a nested "if :else if" and we see the same effect on the first div. This is where things get interesting, I now take that exact code and place it within a div. The first div, after the <, is still not foldable. But, additionally, every wrapping ":else if" also is no longer foldable. I have seen this in some of my more complex files but was always frustrated in figuring out why large blocks would not fold.
folding issue.txt
image

@Ray57
Copy link
Author

Ray57 commented Oct 20, 2024

FYI - Obviously it is not a critical issue. Now that I know it exist, it is simple to reverse. {#if 0 > step} which correctly folds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants