microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.53k stars 1.56k forks source link

Code folding with `//#region` and `//#endregion` #7511

Open wrgallo opened 3 years ago

wrgallo commented 3 years ago

Type: Feature Request

Please make //#region and //#endregion folding available on VSCode for C/C++ too.

Feature request suggested by @Colengms in https://github.com/microsoft/vscode/issues/123016#issuecomment-837074185_

The documentation describes that C/C++ region should be defined with #pragma region and #pragma endregion, although many C/C++ application complain about unknown pragma, generating many warnings. In the very same documentation, the default for many languages is //#region and //#endregion which is definitely the very best choice for C/C++. There are VS Code extensions like this that try to fix these annoying issue, but they create other problems, since single line comments should never use /* */, it makes harder to comment out a block with regions inside.

VS Code version: Code 1.55.2 (3c4e3df, 2021-04-13T09:35:57.887Z) OS version: Windows_NT x64 6.1.7601 ms-vscode.cpptools Version 1.3.1: April 19, 2021

sean-mcmanus commented 3 years ago

I've filed a VS feature request at https://developercommunity.visualstudio.com/t/C-code-folding-for-region/1418674 since some of the outlining is implemented in our shared code.

It would be good if someone could get #pragma region recognition added to gcc as well.

Aukstkalnis commented 3 years ago

Is there any plans to add //#regino folding in upcoming update? Can you provide any settings configuration to make //#region folding to work for now?

wrgallo-navitas commented 3 years ago

Is there any plans to add //#regino folding in upcoming update? Can you provide any settings configuration to make //#region folding to work for now?

I would like to know that too...

At this moment I am using custom region folding with this extension, and this piece of JSON:

"maptz.regionfolder": {
    "[cpp]": {
        "foldEnd": "//#endregion",
        "foldEndRegex": "[#]?endregion",
        "foldStart": "[NAME]",
        "foldStartRegex": "//[\\s]*[#]?region[\\s]*(.*)",
        "disableFolding": false
    }
}

It works with:

sean-mcmanus commented 3 years ago

This issue (and/or the linked VS one) could use more upvotes. It's not currently planned for a update in the near future.

Aukstkalnis commented 3 years ago

Is it thar hard to implement this feature? Maybe you can take code from #region folding for VS Code extention and it wil be done? 🤭

sean-mcmanus commented 3 years ago

@Aukstkalnis I don't know if it's hard or not. We're just working on other features at the moment.

SubaruArai commented 1 year ago

A quick grep of the source code with pragma or region didn't return anything likely to be where this is defined. Can anyone who knows the project structure point me towards where/what to look for?

sean-mcmanus commented 1 year ago

@SubaruArai The code folding code is implemented in our closed source cpptools process that is shared with VS.

SubaruArai commented 1 year ago

@sean-mcmanus Oh, okay. Thought I'd make a PR if it was open source. Thanks anyways!

LeonnardoVerol commented 1 year ago

+1

icon-ramico commented 1 year ago

after I write #endregion it's not clear how to write text under the fold