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
Hi! Thanks for building syntax_tree, I've started using it recently and am excited to enter a new world of not caring about code formatting in Ruby. I noticed one behavior that I'm not sure if it's intentional or not. When I have a constructor with a block argument, the constructor gets split onto a new line even if it would fit within the print width. The easiest example comes from the OptionParser documentation (in fact, I experienced this from code that I had based on this example). I don't know if it's specific to constructors or assignment, haven't really delved into other scenarios yet.
For this example I think I have print-width set to 100 (at least, I have a ~/.streerc with that set, though I am not 100% sure if it is read from the home directory).
require'optparse'Options=Struct.new(:name)classParserdefself.parse(options)args=Options.new("world")opt_parser=OptionParser.newdo |opts|
opts.banner="Usage: example.rb [options]"opts.on("-nNAME","--name=NAME","Name to say hello to")do |n|
args.name=nendopts.on("-h","--help","Prints this help")doputsoptsexitendendopt_parser.parse!(options)returnargsendendoptions=Parser.parse%w[--help]
How syntax_tree formats it:
require"optparse"Options=Struct.new(:name)classParserdefself.parse(options)args=Options.new("world")opt_parser=OptionParser.newdo |opts|
opts.banner="Usage: example.rb [options]"opts.on("-nNAME","--name=NAME","Name to say hello to")do |n|
args.name=nendopts.on("-h","--help","Prints this help")doputsoptsexitendendopt_parser.parse!(options)returnargsendendoptions=Parser.parse%w[--help]
In particular, this is the part that surprises me:
It seems kind of odd because by doing this it ends up indenting the block closing end one extra step, which looks slightly weird to me. I am guessing this is probably intentional, but I'm curious what the reason is behind this formatting. Thanks!
Addendum: It does look like it's just with any assignments that take a multi-line block.
It turns this:
a=[1,2,3]b=a.eachdo |x|
y=x**2 + 2 * x + 1[x,y]end.to_hpb
into this:
a=[1,2,3]b=a.eachdo |x|
y=x**2 + 2 * x + 1[x,y]end.to_hpb
Truthfully, I feel like the output is pretty odd in this case, but it's kind of a pathological example with such short variable names.
The text was updated successfully, but these errors were encountered:
Hi! Thanks for building syntax_tree, I've started using it recently and am excited to enter a new world of not caring about code formatting in Ruby. I noticed one behavior that I'm not sure if it's intentional or not. When I have a constructor with a block argument, the constructor gets split onto a new line even if it would fit within the print width. The easiest example comes from the OptionParser documentation (in fact, I experienced this from code that I had based on this example). I don't know if it's specific to constructors or assignment, haven't really delved into other scenarios yet.
For this example I think I have print-width set to 100 (at least, I have a
~/.streerc
with that set, though I am not 100% sure if it is read from the home directory).The OptionParser example
How syntax_tree formats it:
In particular, this is the part that surprises me:
It seems kind of odd because by doing this it ends up indenting the block closing
end
one extra step, which looks slightly weird to me. I am guessing this is probably intentional, but I'm curious what the reason is behind this formatting. Thanks!Addendum: It does look like it's just with any assignments that take a multi-line block.
It turns this:
into this:
Truthfully, I feel like the output is pretty odd in this case, but it's kind of a pathological example with such short variable names.
The text was updated successfully, but these errors were encountered: