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

Feature Request: Folding regions for Rust #55648

Closed
PaulHale opened this issue Aug 2, 2018 · 12 comments · Fixed by #57069
Closed

Feature Request: Folding regions for Rust #55648

PaulHale opened this issue Aug 2, 2018 · 12 comments · Fixed by #57069
Assignees
Labels
editor-folding Editor code folding issues feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@PaulHale
Copy link

PaulHale commented Aug 2, 2018

Folding regions for Rust

The following languages currently have markers defined:

TypeScript/JavaScript: //#region and //#endregion and //region and //endregion
C#: #region and #endregion
C/C++: #pragma region and #pragma endregion
F#: //#region and //#endregion
Powershell: #region and #endregion
VB: #Region and #End Region
CSS/Less/SCSS: /*#region*/ and /*#endregion*/
Coffeescript: #region and #endregion
PHP: #region and #endregion
Bat: ::#region and ::#endregion

Can we please have this functionality for Rust code?
Rust: #region and #endregion would suffice

@vscodebot vscodebot bot added editor editor-folding Editor code folding issues labels Aug 2, 2018
@aeschli aeschli added this to the August 2018 milestone Aug 2, 2018
@aeschli aeschli added the feature-request Request for new features or functionality label Aug 3, 2018
aeschli added a commit that referenced this issue Aug 24, 2018
@aeschli aeschli added the verification-needed Verification of issue is requested label Aug 27, 2018
@isidorn
Copy link
Contributor

isidorn commented Aug 28, 2018

This works for me nicely if the #region and #endregion are indented all the way to the left. However if they are a bit indented it does not work. @aeschli is this expected?
Here's an example where it is not working (notice the indentation)

fn main() {
    // The statements here will be executed when the compiled binary is called

	#region
 	///my region
	#endregion

    // Print text to the console
    println!("Hello World!");
}

@aeschli
Copy link
Contributor

aeschli commented Aug 28, 2018

Sounds like a bug to me.

@aeschli aeschli reopened this Aug 28, 2018
@PaulHale
Copy link
Author

@isidorn it does work if the code within the #region #endregion is also indented. Kind of forces you to indent your code within regions which I personally like. Not sure if this is by design though.

@aeschli
Copy link
Contributor

aeschli commented Aug 28, 2018

The PR added only// region and // endregion as folding regions. For consistency we should also support // #region and // #endregion. That was the original request and what @isidorn tried.

aeschli added a commit that referenced this issue Aug 28, 2018
@bpasero bpasero added the verified Verification succeeded label Aug 29, 2018
@bpasero
Copy link
Member

bpasero commented Aug 29, 2018

Verified. But the code in the region has to be indented for this to work.

@isidorn
Copy link
Contributor

isidorn commented Aug 29, 2018

@bpasero read my comment from above, this should also work if the code is not indented as well (I justr tried with latest insiders and it is not working). Reopening so @aeschli can decide if this is intended

@isidorn isidorn reopened this Aug 29, 2018
@isidorn isidorn removed the verified Verification succeeded label Aug 29, 2018
@DJMcNab
Copy link
Contributor

DJMcNab commented Aug 29, 2018

A few thoughts:

@aeschli
Copy link
Contributor

aeschli commented Aug 29, 2018

With my fix this should work also indented.

image
image

When testing always use content with the same or smaller indent than the #region. Otherwise you might see the regular indentation based folding regions.

@bpasero What was your example?

@bpasero
Copy link
Member

bpasero commented Aug 29, 2018

@isidorn the one from isidor

@aeschli
Copy link
Contributor

aeschli commented Aug 29, 2018

@bpasero Ah, his example is missing the // before region.

@nrc
Copy link

nrc commented Aug 29, 2018

However, the Rust Style Guide says that a single space after comment markers should be used. I don't know if this we should require this or just leave it up to tools such as rustfmt. It might be worth asking @nrc's opinion for this

We do prefer a space after a comment, however, we use //! for doc comments, so there is precedent for not using a space where there is punctuation which is changing the 'kind' of a comment. On the other hand, these are used //! words not //!words so //#region would still be different.

In general, Rust and it's tools do not have any 'significant' comments and when people have tried to use them there has usually been a negative reaction. So I don't think using //#region or // #region would be popular. However, I can't think of a better way to do it. The Rust way would be #[vscode::region], but these attributes can only be used on specific AST nodes, they can't be used to mark a point in a file. I don't know of a good solution, so perhaps comments are OK.

@bpasero bpasero closed this as completed Aug 30, 2018
@bpasero bpasero added the verified Verification succeeded label Aug 30, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-folding Editor code folding issues feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants