mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Emit folding ranges for multiline array literals
This commit is contained in:
parent
3191a93185
commit
4b555ab1d9
@ -19,6 +19,7 @@ pub enum FoldKind {
|
|||||||
Region,
|
Region,
|
||||||
Consts,
|
Consts,
|
||||||
Statics,
|
Statics,
|
||||||
|
Array,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -119,6 +120,7 @@ fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> {
|
|||||||
match kind {
|
match kind {
|
||||||
COMMENT => Some(FoldKind::Comment),
|
COMMENT => Some(FoldKind::Comment),
|
||||||
ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList),
|
ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList),
|
||||||
|
ARRAY_EXPR => Some(FoldKind::Array),
|
||||||
ASSOC_ITEM_LIST
|
ASSOC_ITEM_LIST
|
||||||
| RECORD_FIELD_LIST
|
| RECORD_FIELD_LIST
|
||||||
| RECORD_PAT_FIELD_LIST
|
| RECORD_PAT_FIELD_LIST
|
||||||
@ -269,6 +271,7 @@ mod tests {
|
|||||||
FoldKind::Region => "region",
|
FoldKind::Region => "region",
|
||||||
FoldKind::Consts => "consts",
|
FoldKind::Consts => "consts",
|
||||||
FoldKind::Statics => "statics",
|
FoldKind::Statics => "statics",
|
||||||
|
FoldKind::Array => "array",
|
||||||
};
|
};
|
||||||
assert_eq!(kind, &attr.unwrap());
|
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]
|
#[test]
|
||||||
fn fold_region() {
|
fn fold_region() {
|
||||||
check(
|
check(
|
||||||
|
@ -497,7 +497,8 @@ pub(crate) fn folding_range(
|
|||||||
| FoldKind::Block
|
| FoldKind::Block
|
||||||
| FoldKind::ArgList
|
| FoldKind::ArgList
|
||||||
| FoldKind::Consts
|
| FoldKind::Consts
|
||||||
| FoldKind::Statics => None,
|
| FoldKind::Statics
|
||||||
|
| FoldKind::Array => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let range = range(line_index, fold.range);
|
let range = range(line_index, fold.range);
|
||||||
|
Loading…
Reference in New Issue
Block a user