QB64Team / qb64

BASIC for the modern era.
https://www.qb64.org
Other
671 stars 96 forks source link

Single level of indentation after multiple colon-separated statement openers #176

Open dkearns opened 3 years ago

dkearns commented 3 years ago

It appears to be a reasonably common style to format nested statements, usually loops, like this:

WHILE 0: WHILE 0
    PRINT "42"
WEND: WEND

Whether this is good style is, hopefully, a question for another day. However, I've noticed that the IDE is currently indenting the contained statement block once for each level of statement nesting.

The aim of this formatting style is presumably to keep things compact so I was wondering if it might be better to use a single level of indentation here?

I noticed this because my inherited legacy code, which uses this style heavily, was formatted with a single indent level.

Thanks, Doug

FellippeHeitor commented 3 years ago

You will probably hate what happens with:

FOR i = 1 TO 10
    FOR j = 1 TO 10
        PRINT a
NEXT j, i

I still think it's all behaving as expected.

dkearns commented 3 years ago

No, I think that's the only sensible way to format your example (i.e., the indent level should be relative to the line above).

FWIW, having a quick look through my QB64 samples archive I note at least one example in wetspot.bas but you could probably find examples of any formatting you like in that archive.

FellippeHeitor commented 2 years ago

Changes previously applied with https://github.com/QB64Team/qb64/commit/1e679627f4edf2a02cc7ba5757526c9f205a6be1 have been reverted until a more stable solution can be found.

Sample code giving issues:

FOR y%% = 0 TO 3: FOR x%% = 0 TO 7
    IF 1 THEN
        PRINT
        END IF
NEXT x%%, y%%