namin
April 24, 2021, 7:27pm
1
Hi,
Here are two examples that are badly auto-indented because of curly braces (?). Besides, it looks like the ‘Auto-align’ preference is ignored, and auto-indentation always applied.
Example using hash
notemap = { do: 72, re: 74, mi: 76 }
puts "bad indenting"
Example using one-line lambda
inc = lambda {|x| x + 1}
puts inc(2)
What do you think?
Thanks. Best wishes, ~n
Hey @namin ,
welcome to the forums and thanks for the questions
With respect to your first example, I don’t believe that the issue is due to curly braces, rather it seems that the auto-indentation system is getting confused with the do:
which I’m assuming it’s mistaking for a do
keyword.
Looks like the error is here: sonic-pi/beautifier.rb at main · sonic-pi-net/sonic-pi (github.com) The regexp is looking for do
followed by a boundary which I’m assuming :
is being interpreted as. This should be pretty simple to fix
Unfortunately I wasn’t able to replicate your second issue, that indented just fine for me here. Can anyone else replicate it?
namin
April 24, 2021, 10:13pm
3
Thanks, Sam!
Very strange, I can no longer replicate the second issue! That’s good…
1 Like
amiika
April 26, 2021, 1:06pm
4
Related to bad indentation this also happens with two while loops:
y = 1
x = 2
while y<10 do
y+=1
print y
while x<20 do
x+=y
print x
end
end
print y
print x
emlyn
April 26, 2021, 1:24pm
5
I think the do
on a while loop is optional in ruby. If you omit it, then things are indented correctly:
y = 1
x = 2
while y<10
y+=1
print y
while x<20
x+=y
print x
end
end
print y
print x
Although this is just a workaround, the do
is still allowed, so it would be nice if it was indented correctly.
This is true, although I’ve now pushed fixes to both the indentation issues in this thread which will be available in the next beta release
1 Like
nlb
April 30, 2021, 5:36am
7
Hi
What about add "
around your French notes ?