Closed scorpion9979 closed 2 months ago
@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.
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 (https://github.com/microsoft/vscode/pull/69899), Python (https://github.com/microsoft/vscode-python/issues/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?
Overview
This PR introduces support for region comments within Solidity
.sol
files previously mentioned in https://github.com/NomicFoundation/hardhat-vscode/issues/452, addressing the issue where developers were seeking the ability to organize code into collapsible sections for improved readability and navigation.Changes
//#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.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.
\
How to test this feature
.sol
file in VS Code.//#region
and//#endregion
comments around the code you wish to collapse.