Open kbauer opened 3 years ago
Hi @kbauer thanks for the feedback! What do you think @spyder-ide/core-developers ? Maybe there was some reason to have the current different treatments taking into account the length of the line?
In 4.2 in the Editor, not the Console, to throw into the "discussion". I use a space before and after assignment which doesn't seem to matter. It behaves as expected for me
item1 = "abcdefgh"
item2 = "12345678"
a = [item1,
item2
]
abcdefgh = [item1,
item2
]
a = [
item1,
item2
]
abcdefgh = [
item1,
item2
]
# with not space around assignment
a=[
item1,
item2
]
abcdefgh=[
item1,
item2
]
a = [ item1, item2 ]
This is actually an example of the inconsistent behavior. It's just a less obvious example with an indentation of 5 characters.
Good catch. It appears in that example, to be a tradeoff between aligning the text under the [ or adding an extra space to make it appear "correct"
Problem Description
Automatic indentation on printing is inconsistent, when a line-break is inserted before the first item / function argument / key in multi-line argument lists, list expressions and dictionary/set expressions, and the opening parenthesis / bracket / brace is less than 8 characters away from the line indentation.
This is likely strongly related to https://github.com/spyder-ide/spyder/issues/887.
What steps reproduce the problem?
a=[<ENTER>item1,<ENTER>item2]
abcdef=[<ENTER>item1,<ENTER>item2]
abcdefg=[<ENTER>item1,<ENTER>item2]
abcdefghi=[ item1,<ENTER>item2]
What is the expected output? What do you see instead?
I would expect the output to be consistent across both cases, i.e.
but instead for a line length of up to 8 on the first line of the statement, indentation is aligned with the opening bracket,
This feels inconsistent:
Suggestion: Entirely remove special treatment of short first lines. They are already covered consistently by the different treatment of continuation lines, where the opening parenthesis/bracket/brace was followed by an item on the first line. However:
The same issues appear with argument lists including keyword arguments, and braces of dictionary expressions.
More examples
Versions
Dependencies