As a Roblox developer, it is currently too hard to write automatically beautiful code using long if-then-else expressions.
If Roblox is able to address this issue, it would improve my development experience because beautiful code increases productivity.
How it currently auto-formats the code:
currentTrack =
if timeType then
musicPlaylists[playlistSwitchTable[timeType]]
:GetChildren()[math.random(1, #musicPlaylists[playlistSwitchTable[timeType]]:GetChildren())]
else
musicPlaylists[fallbackPlaylist]
:GetChildren()[math.random(1, #musicPlaylists[fallbackPlaylist]:GetChildren())]
How it should format it:
currentTrack =
if timeType then
musicPlaylists[playlistSwitchTable[timeType]]
:GetChildren()[math.random(1, #musicPlaylists[playlistSwitchTable[timeType]]:GetChildren())]
else
musicPlaylists[fallbackPlaylist]
:GetChildren()[math.random(1, #musicPlaylists[fallbackPlaylist]:GetChildren())]
I think it’s a bug because the :GetChildren()[...] line after musicPlaylists[fallbackPlaylist] isn’t indented either, but for some reason I can’t post in #bug-reports even though I got accepted into it so I guess I’ll just pretend it’s an unimplemented feature.
OP is referring to if-then-else expressions, not if-then-else statements. Luau can use if-then-else as an assignment that doesn’t require a closing end, while if-then-else statements still behave (and indent) as expected with vanilla Lua.
I heavily disagree on it putting “then” on a new line. However, I absolutely agree on it adding tablature to the inner contents.
I would heavily prefer if the auto-indentation (not even through just the formatting option) did this:
currentTrack = (
if timeType then
...
else
...
)
Currently it puts the inner-contents on the same tablature and that’s my biggest gripe, because when I copy/paste code around it’ll ruin the formatting I had previously.