Skip to content

Commit b5d41ba

Browse files
Merge #9038
9038: Folding range for return types r=Veykril a=MozarellaMan For issue #8957 ![return type fold](https://user-images.githubusercontent.com/48062697/119979082-5c62e100-bfb2-11eb-9729-1dea1ce74de1.gif) Co-authored-by: Ayomide Bamidele <[email protected]>
2 parents 613649e + b4e936f commit b5d41ba

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
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
Statics,
2020
Array,
2121
WhereClause,
22+
ReturnType,
2223
}
2324

2425
#[derive(Debug)]
@@ -131,6 +132,7 @@ fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> {
131132
COMMENT => Some(FoldKind::Comment),
132133
ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList),
133134
ARRAY_EXPR => Some(FoldKind::Array),
135+
RET_TYPE => Some(FoldKind::ReturnType),
134136
ASSOC_ITEM_LIST
135137
| RECORD_FIELD_LIST
136138
| RECORD_PAT_FIELD_LIST
@@ -300,6 +302,7 @@ mod tests {
300302
FoldKind::Statics => "statics",
301303
FoldKind::Array => "array",
302304
FoldKind::WhereClause => "whereclause",
305+
FoldKind::ReturnType => "returntype",
303306
};
304307
assert_eq!(kind, &attr.unwrap());
305308
}
@@ -560,4 +563,18 @@ where
560563
"#,
561564
)
562565
}
566+
567+
#[test]
568+
fn fold_return_type() {
569+
check(
570+
r#"
571+
fn foo()<fold returntype>-> (
572+
bool,
573+
bool,
574+
)</fold> { (true, true) }
575+
576+
fn bar() -> (bool, bool) { (true, true) }
577+
"#,
578+
)
579+
}
563580
}

crates/rust-analyzer/src/to_proto.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ pub(crate) fn folding_range(
534534
| FoldKind::Consts
535535
| FoldKind::Statics
536536
| FoldKind::WhereClause
537+
| FoldKind::ReturnType
537538
| FoldKind::Array => None,
538539
};
539540

0 commit comments

Comments
 (0)