Skip to content

Commit 41531db

Browse files
committed
Add failing test
1 parent 556f738 commit 41531db

4 files changed

+148
-0
lines changed

crates/ark/src/lsp/folding_range.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,58 @@ function() {
607607
));
608608
}
609609

610+
// Braces in function call
611+
//
612+
// FIXME: Ideally folding should look like:
613+
// ```
614+
// call({ ...
615+
// })
616+
// ```
617+
//
618+
// Currently it looks like:
619+
// ```
620+
// call({ ...
621+
// ```
622+
//
623+
// That's because the frontend selects the largest range, which in this case
624+
// is the range for `(`. Our adjustment logic to shift the end of the range
625+
// one line up when the closing delimiter is on its own line doesn't work
626+
// for `)` because `}` is in the way. As a consequence `end_character` is
627+
// `Some` in these snapshots and `end_line` is one line too high.
628+
#[test]
629+
fn test_folding_brace_in_call() {
630+
insta::assert_debug_snapshot!(test_folding_range(
631+
"
632+
call({
633+
1
634+
})
635+
"
636+
));
637+
}
638+
639+
#[test]
640+
fn test_folding_brace_in_call_prefix_arg() {
641+
insta::assert_debug_snapshot!(test_folding_range(
642+
"
643+
call(foo, {
644+
1
645+
})
646+
"
647+
));
648+
}
649+
650+
#[test]
651+
fn test_folding_brace_in_call_prefix_postfix_args() {
652+
insta::assert_debug_snapshot!(test_folding_range(
653+
"
654+
call(foo, {
655+
1
656+
},
657+
bar)
658+
"
659+
));
660+
}
661+
610662
// Test for nested, complex code structures
611663
#[test]
612664
fn test_folding_complex_nested() {
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
source: crates/ark/src/lsp/folding_range.rs
3+
expression: "test_folding_range(\"\ncall({\n 1\n})\n\")"
4+
---
5+
[
6+
FoldingRange {
7+
start_line: 1,
8+
start_character: Some(
9+
6,
10+
),
11+
end_line: 2,
12+
end_character: None,
13+
kind: Some(
14+
Region,
15+
),
16+
collapsed_text: None,
17+
},
18+
FoldingRange {
19+
start_line: 1,
20+
start_character: Some(
21+
5,
22+
),
23+
end_line: 3,
24+
end_character: Some(
25+
0,
26+
),
27+
kind: Some(
28+
Region,
29+
),
30+
collapsed_text: None,
31+
},
32+
]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
source: crates/ark/src/lsp/folding_range.rs
3+
expression: "test_folding_range(\"\ncall(foo, {\n 1\n})\n\")"
4+
---
5+
[
6+
FoldingRange {
7+
start_line: 1,
8+
start_character: Some(
9+
11,
10+
),
11+
end_line: 2,
12+
end_character: None,
13+
kind: Some(
14+
Region,
15+
),
16+
collapsed_text: None,
17+
},
18+
FoldingRange {
19+
start_line: 1,
20+
start_character: Some(
21+
5,
22+
),
23+
end_line: 3,
24+
end_character: Some(
25+
0,
26+
),
27+
kind: Some(
28+
Region,
29+
),
30+
collapsed_text: None,
31+
},
32+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
source: crates/ark/src/lsp/folding_range.rs
3+
expression: "test_folding_range(\"\ncall(foo, {\n 1\n},\nbar)\n\")"
4+
---
5+
[
6+
FoldingRange {
7+
start_line: 1,
8+
start_character: Some(
9+
11,
10+
),
11+
end_line: 2,
12+
end_character: None,
13+
kind: Some(
14+
Region,
15+
),
16+
collapsed_text: None,
17+
},
18+
FoldingRange {
19+
start_line: 1,
20+
start_character: Some(
21+
5,
22+
),
23+
end_line: 4,
24+
end_character: Some(
25+
2,
26+
),
27+
kind: Some(
28+
Region,
29+
),
30+
collapsed_text: None,
31+
},
32+
]

0 commit comments

Comments
 (0)