PY-11357 Adjust range of PSI elements if one of them wraps another

Python does not have special terminal symbols to indicate start/end of
the block. Because of that current approach for searching boundaries for
custom folding region may result in that one of elements "felt of the
cliff" of statement list and is too far above. E.g. in sample given by
user for the last method these elements are PyFunction and PyClass.
However if exactly one element was selected by user and both elements
ends at the same offset it's safe to pick the nested one.
This commit is contained in:
Mikhail Golubev
2014-10-31 12:39:29 +03:00
parent 0919cff107
commit 5a383961d2
4 changed files with 80 additions and 3 deletions
@@ -0,0 +1,15 @@
class ThisIsATest():
<selection>def __init__(self):
self.test = 1</selection>
def another_one(self):
print "Hello, world!"
def another_two(self):
print "Hello, world!"
def another_three(self):
print "Hello, world!"
def another_four(self):
print "Hello, world!"
@@ -0,0 +1,15 @@
class ThisIsATest():
def __init__(self):
self.test = 1
def another_one(self):
print "Hello, world!"
def another_two(self):
print "Hello, world!"
def another_three(self):
print "Hello, world!"
<selection>def another_four(self):
print "Hello, world!"</selection>