Skip to content

Commit 0c0d648

Browse files
bors[bot]Veykril
andauthored
Merge #8412
8412: Emit folding ranges for multiline array literals r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 parents 3191a93 + 4b555ab commit 0c0d648

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

crates/ide/src/folding_ranges.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub enum FoldKind {
1919
Region,
2020
Consts,
2121
Statics,
22+
Array,
2223
}
2324

2425
#[derive(Debug)]
@@ -119,6 +120,7 @@ fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> {
119120
match kind {
120121
COMMENT => Some(FoldKind::Comment),
121122
ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList),
123+
ARRAY_EXPR => Some(FoldKind::Array),
122124
ASSOC_ITEM_LIST
123125
| RECORD_FIELD_LIST
124126
| RECORD_PAT_FIELD_LIST
@@ -269,6 +271,7 @@ mod tests {
269271
FoldKind::Region => "region",
270272
FoldKind::Consts => "consts",
271273
FoldKind::Statics => "statics",
274+
FoldKind::Array => "array",
272275
};
273276
assert_eq!(kind, &attr.unwrap());
274277
}
@@ -464,6 +467,20 @@ fn foo<fold arglist>(
464467
)
465468
}
466469

470+
#[test]
471+
fn fold_multiline_array() {
472+
check(
473+
r#"
474+
const FOO: [usize; 4] = <fold array>[
475+
1,
476+
2,
477+
3,
478+
4,
479+
]</fold>;
480+
"#,
481+
)
482+
}
483+
467484
#[test]
468485
fn fold_region() {
469486
check(

crates/rust-analyzer/src/to_proto.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,8 @@ pub(crate) fn folding_range(
497497
| FoldKind::Block
498498
| FoldKind::ArgList
499499
| FoldKind::Consts
500-
| FoldKind::Statics => None,
500+
| FoldKind::Statics
501+
| FoldKind::Array => None,
501502
};
502503

503504
let range = range(line_index, fold.range);

0 commit comments

Comments
 (0)