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

folding range support #1704

Closed
BigBoulard opened this issue Oct 25, 2022 · 1 comment
Closed

folding range support #1704

BigBoulard opened this issue Oct 25, 2022 · 1 comment
Labels
feature request New feature or request Fixed Fixed in master branch. Pending production release.

Comments

@BigBoulard
Copy link

BigBoulard commented Oct 25, 2022

Hi guys,

In a Svelte file, when params of a function are not on the same line, I can't fold the whole function. I can instead only fold the function params.

async function lambda(
    param1,
    param2,
    param3
  ) {
	const a = 1;
	const b = 2;
}

becomes

async function lambda(
  ) {
  const a = 1;
  const b = 2;
}

instead of

async function lambda() {}

Unlike .svelte files, it works perfectly on .js ones.

@jasonlyu123 jasonlyu123 added the feature request New feature or request label Oct 25, 2022
@jasonlyu123
Copy link
Member

jasonlyu123 commented Oct 25, 2022

We'll need to implement the folding range feature for this. The current one is an indent-based solution provided by VSCode.

Haven't tried it yet. But I am not sure if the result would be great given we have some limitations with our current approach for typescript features. We might not be able to calculate the folding range when there are syntax errors in the markup. I suspect this would cause the folded range suddenly expand. If it did it is worse than not being able to fold a function.

I did some POC and it seems like VSCode did have some logic to retain folded range. I think we can add this in the future. But since there's already an indent-based solution for folding, We'll probably put this in a lower priority.

@jasonlyu123 jasonlyu123 changed the title code folds on function param instead of the whole function in .svelte file folding range support Sep 22, 2023
dummdidumm pushed a commit that referenced this issue Oct 10, 2023
#1704
#1120

This adds the syntactic folding range support instead of the VSCode's default indentation-based and regex-based folding. For embedded languages like Pug and Sass, I added a simplified version of indentation folding. The indentation folding is also a fallback for svelte blocks if there is a parser error.
@dummdidumm dummdidumm added the Fixed Fixed in master branch. Pending production release. label Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request Fixed Fixed in master branch. Pending production release.
Projects
None yet
Development

No branches or pull requests

3 participants