You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Has the idea of disabling formatting for a single line, using a special trailing comment, been discussed before? I searched the tracker but I couldn't find one.
My motivating example - a codebase had the following:
my_variable = if ismissing(row.VarValue)
get_default_val(row.OtherVal, distance)
else
row.VarValue
end,
which I found less desirable. I wanted to stick something like #! nofmt or similar at the end of the line, but apparently no such directive exists, so I'm doing this:
#! format: off
my_variable = ismissing(row.VarValue) ? get_default_val(row.OtherVal, distance) : row.VarValue,
#! format: on
But I don't love having 3 lines where 1 would do, and having 2/3 of the lines just there to avoid this issue. Would love to know your thoughts.
Thanks.
(BTW, I'm probably going to change this existing code to @coalesce row.VarValue get_default_val(row.OtherVal, distance), but I'm not sure everybody likes that and it's a little beside the main point.)
The text was updated successfully, but these errors were encountered:
I think this is a cool idea. #215 (comment) is interesting as well. The flags (indent and margin) would require making edits in a few files though since we would want that specific part to be formatted according to the new indent and margin.
I'm in the middle of moving parts to JuliaSyntax which makes things like this easier since the tree has full knowledge of comments, semicolons, string literals and other things.
But I think my stance on indents/margin being variable is that it is a bad idea. But maybe the concept of disabling format for a single line could be done with an inline comment so:
my_variable =ismissing(row.VarValue) ?get_default_val(row.OtherVal, distance) : row.VarValue, # format: off
which would be treated as the 3 line version. Pretty sure that requires only editing document.jl to capture it.
Has the idea of disabling formatting for a single line, using a special trailing comment, been discussed before? I searched the tracker but I couldn't find one.
My motivating example - a codebase had the following:
The formatter wanted to change it to this:
which I found less desirable. I wanted to stick something like
#! nofmt
or similar at the end of the line, but apparently no such directive exists, so I'm doing this:But I don't love having 3 lines where 1 would do, and having 2/3 of the lines just there to avoid this issue. Would love to know your thoughts.
Thanks.
(BTW, I'm probably going to change this existing code to
@coalesce row.VarValue get_default_val(row.OtherVal, distance)
, but I'm not sure everybody likes that and it's a little beside the main point.)The text was updated successfully, but these errors were encountered: