-
Notifications
You must be signed in to change notification settings - Fork 6
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
Code folding for sections #212
Comments
Thank you for your suggestion! I agree that it can be very helpful to collapse defined sections. We actually introduced the More about the topic can be found here. Can this work for you? |
Thanks for your quick answer. Cool, I didn't know the However, I don't think it really compares to what I suggest. The point is that GAMS models can lead to very big files that can be difficult to navigate. Basically, if you don't remember exactly the name of the equation you are looking for, it takes endless scrolling. So, the folding structure should be properly nested. OK, you can nest You cannot replicate the quick navigation I showed in my gif with your approach. Plus it takes two lines instead of one and visually when unfolded it does not look like separated sections. In RStudio, code sections lead to a nice outline (see https://posit.co/blog/rstudio-v1-4-preview-little-things/). The outline is both in the text, when everything is folded and in an outline pane for quick navigation (cool but a bit redundant). When looking at the text, it is pretty clear the section level you are in. In RStudio, you can fold some code (like the body of a function) as in GAMS Studio, but also blocks of code through the sectioning system. The fact that the sectioning system is based on comments makes it transparent to the user (much more than |
OK, I see your point and we'll discuss how to proceed here. |
It would be great to extend the code folding feature, which is limited to a very small set of code blocks for now, to work with whole sections.
This would allow quick navigation in big models by jumping to the proper section after folding everything.
One question is how to define code sections. One reasonable approach would be to follow RStudio approach, which would translate as defining a section by a line starting with a comment character and that contains at least four dashes:
This is compatible with the language and is easy to type and parse.
Here is an example of what it gives in emacs, where I have just implemented it:
The icing on the cake would be to add a different syntax highlighting for section headings to distinguish them from simple comments, as I did in the emacs example.
I don't need this feature in GAMS Studio since I program in emacs, but having this in GAMS Studio would create a standard for code section and prevent me from fighting with co-authors who would not see the point of writing comments like this and would break my flow.
The text was updated successfully, but these errors were encountered: