In part 1 of this series, I wrote about three features that make TwinBasic's VS Code integration a joy to work with:
- Go to definition (and peek definition)
- Semantic highlighting
Let's continue exploring.
Code folding allows you to collapse logical portions of your code. This allows you to pick and choose which parts of your code you want to see on screen at any given time. You can show the relevant bits and collapse the irrelevant bits out of the way. It's a great way to increase the signal to noise ratio of your workspace.
I should point out that at this stage of the project, the code folding has not been customized for the TwinBasic language. Rather, it uses indentation to determine where to begin and end blocks of code. I would call this "naive code folding" as it ignores the structure of the language itself.
An improvement would be what I'll call "semantic code folding." In semantic code folding, the development environment groups blocks logically according to the language grammar. For example, an
If statement would mark the start of a code folding block which would continue until it found the matching
End If statement.
This sounds simple on its face, but there are challenges in implementing such a system, including nested statements, multiple statements on a single line via the colon operator (
:), etc. Here's to hoping semantic code folding makes an appearance in TwinBasic at some point in the future.
Inline parameter hints
One of the coolest features in TwinBasic's VS Code extension is the inline parameter hints. This feature lets you toggle the VBA parameter naming syntax on and off without actually changing your code. Here's an example of how this works:
If you have explicitly named some of the parameters in your code, those are unaffected by toggling the parameter hints on and off:
The final feature I want to talk about is the Outline view. This is a foldable view of your code grouped by logical sections: modules, routines (functions/subs), custom types, declared variables, etc.
If you click on any of the entries in the list, VS Code takes you straight to that line of code within the editor: