Vetur: Make `#region` work on `<script>` section

Created on 11 Sep 2018  路  22Comments  路  Source: vuejs/vetur

From https://github.com/Microsoft/vscode/issues/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.

feature-request typescript folding

Most helpful comment

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

All 22 comments

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

image

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 ;)

https://github.com/vuejs/vetur/blob/2cf32f2b6f345a215e184a7ec9b028419ec803ee/languages/vue-language-configuration.json#L33-L38

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

@Hammster VS Code now has 3 types of folding

@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?

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?

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

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

Much needed. Any news on that?

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

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

+1

+1

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

+1 would love to see this

+1 This is definitely needed. Any update?

+1 This is useful

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

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

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

@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

@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?

@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...

Was this page helpful?
0 / 5 - 0 ratings