镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

// #regions #11073

Description

From Max Beckenbach (@mbeckenbach) on September 16, 2016 12:48

  • VSCode Version: 1.5.2
  • OS Version: Win10

Would be great to have //#region support in typescript

Copied from original issue: microsoft/vscode#12146

Activity

  1. waderyan commented on Sep 23, 2016

    @waderyan
    Author

    Max Beckenbach (@mbeckenbach) can you provide more information of what you are looking for? I am not familiar with //#region support.

    Also, is this VS Code specific or is this a feature request for TypeScript? This may be better in TypeScript.

  2. waderyan commented on Sep 23, 2016

    @waderyan
    Author

    From Max Beckenbach (@mbeckenbach) on September 19, 2016 8:38

    The full visual studio uses comments to mark code blocks as collapsable in all languages. Depending on the language, the syntax is slightly different as the comment syntax is different.

    Hard to explain, but web essentials has a nice screenshot of regions in the javascript area: http://vswebessentials.com/features/javascript

    Regions should exist for all languages. The comment syntax is different but the result schould be the same.

  3. waderyan commented on Sep 23, 2016

    @waderyan
    Author

    From Diego Vieira (@divieirasilva) on September 19, 2016 17:50

    I think, Max Beckenbach (@mbeckenbach) are talking about the #region, current present on c# syntax of Visual Studio. Currently, on C#, #region name_region is used to tell where code will start folding and #endregion tells where code will stop folding.
    I'm really missing this feature on VS Code as well, all my code have regions for better code reading and on VSCode I can't fold my regions.

    e.g.

    #region region_sample

    void MyDummyMethod()
    {
    int a = 1 + 1;
    }

    void MyDummyMethod2()
    {
    int b = 1 + 1;
    }

    #endregion

    In the sample above, the entire region block should fold and "region_sample" should be the label on folding.

  4. waderyan commented on Sep 23, 2016

    @waderyan
    Author

    From Max Beckenbach (@mbeckenbach) on September 20, 2016 5:56

    yes, that's what i'm talking about. i'm really missing that feature in other languages like for example ts

  5. waderyan commented on Sep 23, 2016

    @waderyan
    Author

    Ryan Cavanaugh (@RyanCavanaugh) I'm guessing you have thought about adding something like this before.

  6. changed the title [-]Regions[/-] [+]// #regions[/+] on Sep 23, 2016
  7. mhegazy commented on Sep 23, 2016

    @mhegazy
    Contributor

    // #region support is really a webessentials feature. personally i find it fairly foreign to the JS language and tooling. implementing it is not straight forward, since these are comments at the end of the day. keeping the issue open awaiting more user feedback to see if there is enough demand.

  8. 42 remaining items

  9. added
    FixedA PR has been merged for this issue
    and removed
    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this feature
    on Sep 18, 2017
  10. khcjump commented on Oct 5, 2017

    @khcjump

    +1 as C#

  11. pleerock commented on Oct 12, 2017

    @pleerock

    I came here accidentally, but this really looks weird feature non-related to the language semantics.

    It looks like users want to monkey-patching big files instead of extracting contents into separate files that is true way of proper code organization.

    When we are considering " 👍 " we should keep in mind that people who are interested in this feature come more here then people who aren't. Ratio maybe very high, so maybe its not a good idea to pollute language based on limited number of opinions most of which are given based on their own needs.

  12. bradleyayers commented on Oct 17, 2017

    @bradleyayers

    Is there any commentary on the design rationale for including this in TypeScript (the language) rather than in the editor (VS Code)? This is a very surprising decision to me, and I'd love to get a better understanding of the thinking behind it.

  13. mhegazy commented on Oct 17, 2017

    @mhegazy
    Contributor

    Is there any commentary on the design rationale for including this in TypeScript (the language) rather than in the editor (VS Code)? This is a very surprising decision to me, and I'd love to get a better understanding of the thinking behind it.

    Not sure i understand what you mean by the "language". TypeScript has no special treatment for the text in the comment. The TypeScript language service, which is what drives the JS and TS experience in VS, VSCode, etc.. is what supports this as an outlining span, i.e. you get the little +/- to expand and contract the region.

    Why is it added to the language service, cause users seem to like it and asked for it.

  14. uniqueiniquity commented on Oct 17, 2017

    @uniqueiniquity
    Contributor

    The general idea was to build this into the existing "getOutliningSpans" functionality of the TypeScript Language Service so that it can be consumed by multiple editors. However, afaik VS Code doesn't actually use the Language Service for outlining spans; they've decided to calculate the block outlining on their own. They have introduced their own support for //#region as of VS Code 1.17.

  15. bradleyayers commented on Oct 17, 2017

    @bradleyayers

    That makes a lot more sense — thanks for the clarification!

    I got the wrong impression from reading the item on https://github.com/Microsoft/TypeScript/wiki/Roadmap for 2.6. For some reason I assumed it was a language/compiler feature rather than being a language services feature. Being part of language services seems pretty reasonable to me!

    Re-reading the roadmap updates it seems obvious now, especially given it comes after the 'Refactors to…' and 'Quick fixes to…' sections. My bad!

  16. thewebchameleon commented on Jan 17, 2018

    @thewebchameleon

    +1

  17. mattmc3 commented on Jun 12, 2018

    @mattmc3

    Added a similar feature request for the SQLOps team to add this for SQL folding too. Not sure why this wouldn't just be implemented as folding for #region/#endregion detected as comment in any language. microsoft/azuredatastudio#1618

  18. PostImpatica commented on Aug 5, 2019

    @PostImpatica

    For those coming here late like me, yes this was implemented.

    use:

    //#region whatever
    //#endregion
    
  19. Sti2nd commented on Nov 21, 2021

    @Sti2nd

    Just wondering, is this really a Typescript language feature? It wasn't mentioned in the Typescript 2.6 release notes.

    From this comment, it seems like the feature was implemented in the language server: #29379 (comment)

  20. felipemullen commented on Jul 21, 2022

    @felipemullen

    Thanks to the devs who added this. Very helpful in code organization, even in small files (i.e. separating static methods from instance methods).

    For anyone arriving from the web, I made a vscode snippet to add these in with fewer keystrokes:

    "region": {
        "prefix": "region",
        "body": [
            "//#region ${1:Name}",
            "$0",
            "//#endregion"
        ]
    }

    https://github.com/proxy/gist.github.com/felipemullen/316c372c2aed83091d05b27f147db337

  21. fattah-behmadi commented on Oct 4, 2023

    @fattah-behmadi

    You can use from below structure in VSCode without config or setting.

    //#region Calculate function const calculate = (x: number, y: number) => { return x + y; }; //#endregion

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

Metadata

Metadata

Labels

FixedA PR has been merged for this issueSuggestionAn idea for TypeScriptVS Code TrackedThere is a VS Code equivalent to this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions