Pizzaandy / Gobo

Gobo is an opinionated code formatter for GameMaker Language.
https://pizzaandy.github.io/Gobo/
MIT License
20 stars 1 forks source link

Feature: Setting to indent regions #11

Closed adam-coster closed 4 months ago

adam-coster commented 4 months ago

I've been playing around with Gobo a bit to see how it would format some of our code. So far the only issue is that our main game programmer makes frequent use of #regions, including nested regions, to organize code.

Since #region is an official keyword rather (rather than a JavaScript-style comment convention) it would make sense to include it in the AST and indent the contents of a region. And if we're doing that, also indent nested regions recursively!

That may be out of scope, but I suspect that a lot of GameMaker programmers make heavy use of regions to organize code so the use-case is probably there.

Pizzaandy commented 4 months ago

I don't think this is possible for the following reasons: a) Dangling #region and #endregion statements are allowed by the compiler b) Regions can contain opening/closing brackets

#region hmm
#region how do we indent this
if (true) {
#endregion
}
adam-coster commented 4 months ago

Ah yeah, good points. The former issue is probably fine since you could have implicit endings at EOF, but the latter is definitely weird.