Files
openide/python/testData/copyPaste/TopLevelFunctionWithMultilineParameterList.after.py
Mikhail Golubev 2ca4c00fcf PY-19100 Properly detect that the first line of pasted text needs to be additionally indented
It becomes necessary when user copies compound statement
staring selection at the beginning of the first keyword like
"def" instead of using structural selection. Because of that
we lose indentation of that first line and whole underlying block
structure becomes ambiguous, i.e. it's no longer clear which of the
following lines belong to the body of such function and which
were at the same or smaller block level initially. To handle it
we use simple heuristic that detects whether the body of copied
function is  indented too much and if it's the case we shift
the first line further to the right as if the etire first line
was copied in the first place.

Previously we compared indentation of the first two lines for this
purpose and it didn't work for various compound statements that may
have multiline header, e.g. function definition with individual
parameters on their own lines, "if" statement or "while" loop which
condition spans multiple lines etc. Now we first parse pasted
fragment and then take the indentation of the actual statement list.
2016-07-06 21:09:54 +03:00

6 lines
66 B
Python

def hello(x,
y):
"""
foo
"""
return None