aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/folding_ranges.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-09-19 16:56:38 +0100
committerGitHub <[email protected]>2019-09-19 16:56:38 +0100
commit44bab3621d74f1aec922300a3b3f4476907ba2ac (patch)
tree35b400e0cb3efdb2298e8dfba9447b9048050164 /crates/ra_ide_api/src/folding_ranges.rs
parent4eb0bb4810d872a8dff176d22c108974c3d4b109 (diff)
parent2be9031935c92c4837c2d16e7dd503658108524b (diff)
Merge #1873
1873: `fold_kind`: `MATCH_ARM_LIST => FoldKind::Block` r=matklad a=Centril As suggested by @matklad in https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/folding.20of.20.60match.60.20and.20.60if.60/near/176109093. This should let folks fold all the arms in a `match` expression rather than just each arm individually. Co-authored-by: Mazdak Farrokhzad <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src/folding_ranges.rs')
-rw-r--r--crates/ra_ide_api/src/folding_ranges.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/crates/ra_ide_api/src/folding_ranges.rs b/crates/ra_ide_api/src/folding_ranges.rs
index 3ab6c195e..79fadcc5d 100644
--- a/crates/ra_ide_api/src/folding_ranges.rs
+++ b/crates/ra_ide_api/src/folding_ranges.rs
@@ -87,6 +87,7 @@ fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> {
87 | EXTERN_ITEM_LIST 87 | EXTERN_ITEM_LIST
88 | USE_TREE_LIST 88 | USE_TREE_LIST
89 | BLOCK 89 | BLOCK
90 | MATCH_ARM_LIST
90 | ENUM_VARIANT_LIST 91 | ENUM_VARIANT_LIST
91 | TOKEN_TREE => Some(FoldKind::Block), 92 | TOKEN_TREE => Some(FoldKind::Block),
92 _ => None, 93 _ => None,
@@ -358,4 +359,18 @@ macro_rules! foo <fold>{
358 let folds = &[FoldKind::Block]; 359 let folds = &[FoldKind::Block];
359 do_check(text, folds); 360 do_check(text, folds);
360 } 361 }
362
363 #[test]
364 fn test_fold_match_arms() {
365 let text = r#"
366fn main() <fold>{
367 match 0 <fold>{
368 0 => 0,
369 _ => 1,
370 }</fold>
371}</fold>"#;
372
373 let folds = &[FoldKind::Block, FoldKind::Block];
374 do_check(text, folds);
375 }
361} 376}