That's odd... I set up a test case to try and reproduce, and also to test the difference between ctrl + i
and ctrl + shift + a
which is "reformat code".
I started with a mal-indented nested list:
if (a > b) {
mylist <- list(thing1=1,
thing5 = list(inner1=1,
inner3=list(innerinner1=1
)
)
)
}
first I tried ctrl + i
and, oddly, I think I got the indentation you were looking for
if (a > b) {
mylist <- list(thing1=1,
thing5 = list(inner1=1,
inner3=list(innerinner1=1
)
)
)
}
Then I tried cmd + shift + a
and it didn't like my closing parens on different lines:
if (a > b) {
mylist <- list(thing1 = 1,
thing5 = list(inner1 = 1,
inner3 = list(innerinner1 = 1)))
}
So why isn't yours right? Let's make a strawman that looks more like yours:
if (a > b) {
options(DT.options = list(lageLength=3,
innerlist = list(a=1,b=2)
)
)
Now if I do ctrl + i
here:
if (a > b) {
options(DT.options = list(lageLength=3,
innerlist = list(a=1,b=2)
)
)
oh... well that replicates.
If I do ctrl + shift + a
I get closing parens like previously:
if (a > b) {
options(DT.options = list(lageLength = 3,
innerlist = list(a = 1, b = 2)))
however, I found that if I do a linefeed after the DT.Options =
then it behaves properly:
if (a > b) {
options(DT.options =
list(lageLength = 3,
innerlist = list(a = 1, b = 2)
)
)
I haven't the slightest knowledge of how code formatting logic works on the inside. But it looks like having two levels of nesting on the same line (options(DT.options = list(lageLength = 3,
) throws it a curveball and it doesn't know what to do.