Formatter doesn't indent blank lines, leading to unintuitive behaviour

Here’s a snippet of code that’s just been formatted with the in-built formatter (Format Document):
image

Notice that the blank lines have no tabs - this leads to a whole host of unintuitive and unpleasant behaviour (specifically when using relative indentation).

Firstly, if I move my caret onto that line, it appears too far to the left, and attempting to write code would cause it to have incorrect indentation:

image

Secondly, this messes with the default behaviour for pasting code - if I paste code after a blank line with no tabs, it will appear too far to the left if using relative indentation:

image

In the context of Studio’s other formatting behaviours, removing tabs from empty lines when formatting documents makes no sense, and so far has been a large nuisance in my work. Hopefully this can be resolved quickly :slightly_smiling_face:

2 Likes

Other text editors (such as VSC) behave like this too I believe. I actually prefer blank lines staying blank, without whitespace. It makes much more sense to remove trailing whitespace off blank lines as you would any other line anyways.

It would be a lot less noticeable and welcome if, like VSC, when you move your cursor to a blank line or paste text on one it’s automatically tabbed the right amount.

4 Likes

I’m aware of this - however, since this behaviour causes problems with Studio, I think it’d be better to leave them in.

Alternatively a solution more similar to VS Code is acceptable, though that would take more work. Perhaps this could be a solution in the meantime? :slightly_smiling_face:

edit: This looks like intentional behaviour, and can be toggled here for anyone looking in future:

image

There’s a discussion to be had about how visible these settings are / how it’s easy to miss them, but that’s for another thread :stuck_out_tongue:

(thanks to @sircfenner for pointing this out in DMs :slightly_smiling_face:)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.