8412: Emit folding ranges for multiline array literals r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2021-04-07 22:12:43 +00:00 committed by GitHub
commit 0c0d648b49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -19,6 +19,7 @@ pub enum FoldKind {
Region,
Consts,
Statics,
Array,
}
#[derive(Debug)]
@ -119,6 +120,7 @@ fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> {
match kind {
COMMENT => Some(FoldKind::Comment),
ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList),
ARRAY_EXPR => Some(FoldKind::Array),
ASSOC_ITEM_LIST
| RECORD_FIELD_LIST
| RECORD_PAT_FIELD_LIST
@ -269,6 +271,7 @@ mod tests {
FoldKind::Region => "region",
FoldKind::Consts => "consts",
FoldKind::Statics => "statics",
FoldKind::Array => "array",
};
assert_eq!(kind, &attr.unwrap());
}
@ -464,6 +467,20 @@ fn foo<fold arglist>(
)
}
#[test]
fn fold_multiline_array() {
check(
r#"
const FOO: [usize; 4] = <fold array>[
1,
2,
3,
4,
]</fold>;
"#,
)
}
#[test]
fn fold_region() {
check(

View File

@ -497,7 +497,8 @@ pub(crate) fn folding_range(
| FoldKind::Block
| FoldKind::ArgList
| FoldKind::Consts
| FoldKind::Statics => None,
| FoldKind::Statics
| FoldKind::Array => None,
};
let range = range(line_index, fold.range);