Need linebreak in One-line if/else statement without begin-end

46 views
Skip to first unread message

Audrey

unread,
Dec 14, 2022, 2:32:25 AM12/14/22
to Verible Users
Hello, I'm new to Verible and I was wondering if someone knows a way to make this.

I want my code to be formatted like this:
if (something)
    do something
else
    do something

not this:
if (something) do something
else do something

I found ↓this issue which says exactly opposite to mine:

Also I checked all the flag options but I couldn't find anything that can help me.

Is there any option that can help this situation but I was just not able to find it?
Or is there any other way I can try?

Thanks,
Audrey

David Fang

unread,
Dec 14, 2022, 3:51:28 AM12/14/22
to Audrey, Verible Users
Hi Audrey,
What you are requesting is reasonable, but we haven't exposed the ability to configure this behavior yet. 
In general, it is easy to coerce a line break with end-of-line comments like:

if (something) //
  do something

though this is intended for one-off exceptions, rather than asking the user to do this everywhere.  
You may also disable the formatter over ranges of text, until we make improvements.

In any case, I suggest filing a request to make formatting of single-statement-bodies configurable, and we can flesh out some ideas of what that could look like there, and maybe draw some inspiration from other languages' formatters.  

If you're curious, some of the code that handles conditional is around here.

--
You received this message because you are subscribed to the Google Groups "Verible Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to verible-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/verible-users/ec7ce378-8292-4362-9fe0-304237632633n%40googlegroups.com.

Sergey Sokolov

unread,
Dec 14, 2022, 12:10:27 PM12/14/22
to David Fang, Audrey, Verible Users
Alternatively the user can add begin/end:

if (something) begin
    do something
end else begin
    do something
end

The original formatting I believe was done that way to prevent users from accidentally adding to the else (or bare 'if') block, which is actually not:

if (something)
    do something
else
    do something
    do something 'else', but not

Reply all
Reply to author
Forward
0 new messages