File tree Expand file tree Collapse file tree 2 files changed +26
-5
lines changed
zuban_python/tests/mypylike/tests Expand file tree Collapse file tree 2 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -386,7 +386,13 @@ impl Tree {
386386
387387 pub fn folding_blocks < ' x > ( & ' x self ) -> impl Iterator < Item = ( CodeIndex , CodeIndex ) > {
388388 self . 0 . nodes ( ) . filter_map ( |n| {
389- let end = || n. last_leaf_in_subtree ( ) . previous_leaf ( ) . unwrap ( ) . end ( ) - 1 ;
389+ let end = || {
390+ let mut leaf = n. last_leaf_in_subtree ( ) ;
391+ while leaf. is_type ( Terminal ( TerminalType :: Dedent ) ) {
392+ leaf = leaf. previous_leaf ( ) . unwrap ( ) ;
393+ }
394+ leaf. end ( ) - 1
395+ } ;
390396 if n. is_type ( Nonterminal ( match_stmt) ) {
391397 return Some ( ( n. nth_child ( 3 ) . start ( ) , end ( ) ) ) ;
392398 }
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ def f(something, something_else) -> None:
103103
104104[out]
105105__main__.py:2: Folding Ranges:
106- - 3:41-18:0 Region
106+ - 3:41-17:17 Region
107107- 5:8-6:11 Region
108108- 8:26-11:11 Region
109109- 12:31-13:11 Region
@@ -127,8 +127,8 @@ def f(something) -> None:
127127[out]
128128__main__.py:2: Folding Ranges:
129129- 1:0-2:13 Imports
130- - 4:25-13:8 Region
131- - 5:20-13:8 Region
130+ - 4:25-12:21 Region
131+ - 5:20-12:21 Region
132132- 6:27-7:15 Region
133133- 8:20-9:15 Region
134134- 11:17-12:21 Region
@@ -156,7 +156,7 @@ async def bar():
156156
157157[out]
158158__main__.py:2: Folding Ranges:
159- - 2:25-16:0 Region
159+ - 2:25-15:16 Region
160160- 4:29-5:11 Region
161161- 6:29-7:11 Region
162162- 8:9-9:24 Region
@@ -179,3 +179,18 @@ x = 1
179179[out]
180180__main__.py:2: Folding Ranges:
181181- 6:20-10:7 Region
182+
183+ [case if_nested_folding_range]
184+ #? folding-ranges
185+ def f() -> None:
186+ if bool():
187+ if bool():
188+ ...
189+ else:
190+ ...
191+ [out]
192+ __main__.py:2: Folding Ranges:
193+ - 2:16-7:11 Region
194+ - 3:14-5:15 Region
195+ - 4:18-5:15 Region
196+ - 6:9-7:11 Region
You can’t perform that action at this time.
0 commit comments