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

feat: add support for region comments #526

Merged
merged 3 commits into from
Apr 30, 2024

Conversation

scorpion9979
Copy link
Contributor

@scorpion9979 scorpion9979 commented Nov 3, 2023

  • Because this PR includes a bug fix, relevant tests have been included.
  • Because this PR includes a new feature, the change was previously discussed on an Issue or with someone from the team.
  • I didn't do anything of this.

Overview

This PR introduces support for region comments within Solidity .sol files previously mentioned in #452, addressing the issue where developers were seeking the ability to organize code into collapsible sections for improved readability and navigation.

Changes

  • Modified the Solidity language configuration file to recognize the //#region and //#endregion patterns.

Implementation Details

Region comments are implemented by modifying the Solidity language grammar to include start and end region markers. The pattern follows the typical convention of //#region and //#endregion which is familiar to developers from other programming languages.

//#region ExampleRegion

// Your Solidity code here

//#endregion ExampleRegion

The language configuration now includes logic to parse these markers and translate them into foldable regions within VS Code.

Screenshots

Included are screenshots demonstrating the collapsible regions in action within a Solidity file.

image


image

How to test this feature

  1. Check out this PR and follow the instructions in CONTRIBUTING.md#running-locally to run it locally.
  2. Open a .sol file in VS Code.
  3. Insert //#region and //#endregion comments around the code you wish to collapse.
  4. Verify that you can collapse and expand the region as expected.

@pegahcarter
Copy link

@Xanewok can we get some support on this feat? It would be great to have for navigating large contracts and can prevent a screen-split if you're working on, for example, public functions and their errors or events.

@Xanewok
Copy link
Contributor

Xanewok commented Apr 29, 2024

I'd be open to it; I thought this is a Microsoft/C#-ism but it seems to be ubiquitously supported in languages like Go (microsoft/vscode#69899), Python (microsoft/vscode-python#33) and C++, C#, TS etc.

Ideally:

However, since this is such a small addition, I think it's more beneficial to have it rather than the other way around, especially if users will be migrating from the existing Juan Blanco's extension that supports it.

@kanej what do you think?

docs/publish-extension.md Outdated Show resolved Hide resolved
Copy link
Member

@kanej kanej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested locally. Looks good.

@kanej kanej merged commit e48460d into NomicFoundation:development Apr 30, 2024
2 of 5 checks passed
OmarTawfik pushed a commit that referenced this pull request May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants