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

Make #region work on <script> section #899

Closed
octref opened this issue Sep 10, 2018 · 25 comments
Closed

Make #region work on <script> section #899

octref opened this issue Sep 10, 2018 · 25 comments

Comments

@octref
Copy link
Member

octref commented Sep 10, 2018

From microsoft/vscode#39939. There is no folding regions being returned back from //#region, as VS Code does for TypeScript.

image

This is the foldingRange support for LSP: https://microsoft.github.io/language-server-protocol/specification#textDocument_foldingRange.

@jordan-erisman
Copy link

Just wanted to add that they do not work in the template or style sections either.

image

@Hammster
Copy link

Hammster commented Oct 27, 2018

I'm really missing this feature, i tried playing around with the following values:

EDIT:
After investing some time i understand that the following is not a proper implementation and that the language server should handle it ;)

"folding": {
"markers": {
"start": "^<(template|style|script)[^>]*>",
"end": "^</(template|style|script)>"
}
}

And it actually works by providing the following config:

  "folding": {
    "markers": {
      "start": "(^<(template|style|script)[^>]*>\\b|^\\s*//\\s*#?region\\b)",
      "end": "(^<\/(template|style|script)>\\b|^\\s*//\\s*#?endregion\\b)"
    }
  }

But there are several issues, the folding is only available afer reloading the window, also the indention seams to be off in some of my components which does not allow me to have the content of the region to be on the same or lower level then the region.

folding

Changing the editor.foldingStrategy for vscode fixed the issue from above, i am not sure why this is not auto detected properly though

@octref
Copy link
Member Author

octref commented Nov 5, 2018

@Hammster VS Code now has 3 types of folding

@yankeeinlondon
Copy link

@octref the region folding is the only way a user can explicitly state folding blocks. I'm not sure if that's what you mean by "folding markers" but if so what is unreliable about them?

@mika76
Copy link

mika76 commented Jun 19, 2019

Regions are awesome (especially in long html templates - admit it they happen 😉) and I can't wait for this - especially since this will also allow #1294 which is slightly more irritating

@octref any idea when supporting intelligent folding is going to be implemented?

@momink
Copy link

momink commented Jun 28, 2019

In VScode following is not working in .vue files but works in .js files.
//#region ccc
//#endregion

@phifa
Copy link

phifa commented Jul 1, 2019

This is a great feature addition. Already being worked on? Can we help or test?

@leosdad
Copy link

leosdad commented Aug 2, 2019

Much needed. Any news on that?

@jtsom
Copy link

jtsom commented Oct 9, 2019

Just realized that regions are not available in .vue files. Any news/movement on this? Would be SUPER helpful.

@ghost
Copy link

ghost commented Jan 20, 2020

Hey that's an important feature. Is it being implemented?

@Creestoph
Copy link

+1

1 similar comment
@lysla
Copy link

lysla commented Jun 13, 2020

+1

@saadsidqui
Copy link

+1 THis is actually super important especially in large components.

@sebsobseb
Copy link

+1 would love to see this

@klihonga11
Copy link

+1 This is definitely needed. Any update?

@lala-lee-jobs
Copy link

+1 This is useful

@tonyl
Copy link

tonyl commented Aug 20, 2020

I know I am just another request, but it will come in handy for some code bases.

@octref
Copy link
Member Author

octref commented Aug 25, 2020

The issue is open so there's no update yet. I'll try to make time to implement it.
Meanwhile you can sponsor my OSS development https://github.com/sponsors/octref or add a bounty for this issue: https://issuehunt.io/r/vuejs/vetur

@mika76
Copy link

mika76 commented Aug 25, 2020

@octref that's great news - I think #1294 is related to this (collapsing of tags) in case you're working on this.

@octref octref closed this as completed in 6bec459 Aug 28, 2020
cereschen pushed a commit to cereschen/vetur that referenced this issue Sep 10, 2020
@capar
Copy link

capar commented Nov 4, 2020

@mika76

Hi all, sorry, a beginner question here: Is this normal that the following does not allow me to collapse the lines 39-43? What should I do instead? Thank you. (VS Code with Vetur extension enabled)

image

@yoyo930021
Copy link
Member

@mika76

Hi all, sorry, a beginner question here: Is this normal that the following does not allow me to collapse the lines 39-43? What should I do instead? Thank you. (VS Code with Vetur extension enabled)

image

Is this code in script part?

@mika76
Copy link

mika76 commented Nov 4, 2020

@capar it seems it only works when it has a name, so...

// #region some name
someCode();
// #endregion 

[EDIT] hmm, I tried it again and it works without the name too, so maybe it's something else not working on yours...

@edudins
Copy link

edudins commented Apr 24, 2024

Same here, .vue files doesn't work. And I was so excited. :D

@Owen3H
Copy link

Owen3H commented Apr 28, 2024

Came across this issue and realised I had editor.foldingStrategy to indentation.
Make sure it is set to auto as that's what fixed it for me.

@edudins
Copy link

edudins commented Apr 29, 2024

Came across this issue and realised I had editor.foldingStrategy to indentation.
Make sure it is set to auto as that's what fixed it for me.

Doesn't fix it for me. I already have folding strategy at auto.

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

No branches or pull requests