mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-14 00:40:28 +07:00
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.
5 lines
90 B
Python
5 lines
90 B
Python
<selection>if (True or (True or
|
|
False)):
|
|
x = 1
|
|
y = 2</selection>
|