Editor: fold (...) blocks and whole function definitions
Author: hasselmmCreated Sep 12, 2026Updated Sep 12, 2026
LabelsType: Enhancement
Is your feature request related to a problem?
Code folding in the built-in editor currently only understands {} and []. Two common constructs have no way to collapse:
- Any multi-line call or argument list that only uses plain parentheses — e.g. a multi-line
let(...)definition,object(...)call (see OEP8a, the experimental object() builtin), or any other function/module call whose arguments span several lines. - A
function name(...) = expr; definition. Since function bodies are pure expressions with no braces, even a long, deeply-nested definition (e.g. one built aroundlet(...)) has no single fold point that collapses the whole thing — only its own internal([sub-expressions fold individually.
Describe the solution you'd like
- Treat
(and)the same as the existing{}and[]bracket-depth counting inScadLexer2::fold(). - Additionally fold the entire span of a
function ... = ... ;definition as one region, from the function keyword to its terminating semicolon. Since a function body cannot itself contain a semicolon the first semicolon following the keyword unambiguously terminates it.
Describe alternatives you've considered
I've also considered a more general #region/#endregion-style comment marker (as in VS Code), but that's out of scope here. This issue is only about the two gaps above, which are purely syntax-driven.
Additional context
No test infrastructure currently exercises ScadLexer2; a data-driven QtTest suite (src/guitests/TestScadLexerFolding) is included in the linked PR.
Source: openscad/openscad