From 156d9954236e8dba849bee939c094c337120780a Mon Sep 17 00:00:00 2001 From: Ayomide Bamidele <48062697+MozarellaMan@users.noreply.github.com> Date: Fri, 28 May 2021 12:39:02 +0100 Subject: Folding range for return types --- crates/ide/src/folding_ranges.rs | 15 +++++++++++++++ crates/rust-analyzer/src/to_proto.rs | 1 + 2 files changed, 16 insertions(+) (limited to 'crates') diff --git a/crates/ide/src/folding_ranges.rs b/crates/ide/src/folding_ranges.rs index b893c1c54..ce8473d94 100755 --- a/crates/ide/src/folding_ranges.rs +++ b/crates/ide/src/folding_ranges.rs @@ -19,6 +19,7 @@ pub enum FoldKind { Statics, Array, WhereClause, + ReturnType, } #[derive(Debug)] @@ -131,6 +132,7 @@ fn fold_kind(kind: SyntaxKind) -> Option { COMMENT => Some(FoldKind::Comment), ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList), ARRAY_EXPR => Some(FoldKind::Array), + RET_TYPE => Some(FoldKind::ReturnType), ASSOC_ITEM_LIST | RECORD_FIELD_LIST | RECORD_PAT_FIELD_LIST @@ -300,6 +302,7 @@ mod tests { FoldKind::Statics => "statics", FoldKind::Array => "array", FoldKind::WhereClause => "whereclause", + FoldKind::ReturnType => "returntype", }; assert_eq!(kind, &attr.unwrap()); } @@ -560,4 +563,16 @@ where "#, ) } + + #[test] + fn fold_return_type() { + check( + r#" +fn foo()-> ( + bool, + bool, +) { (true, true) } + "#, + ) + } } diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 6d18d0ffc..f5c8535a2 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -534,6 +534,7 @@ pub(crate) fn folding_range( | FoldKind::Consts | FoldKind::Statics | FoldKind::WhereClause + | FoldKind::ReturnType | FoldKind::Array => None, }; -- cgit v1.2.3 From b4e936f8f09a3f7825de7ca2287d5daa5bf637f3 Mon Sep 17 00:00:00 2001 From: Ayomide Bamidele <48062697+MozarellaMan@users.noreply.github.com> Date: Fri, 28 May 2021 13:10:41 +0100 Subject: Test for correct amount of emitted folds --- crates/ide/src/folding_ranges.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'crates') diff --git a/crates/ide/src/folding_ranges.rs b/crates/ide/src/folding_ranges.rs index ce8473d94..c5015a345 100755 --- a/crates/ide/src/folding_ranges.rs +++ b/crates/ide/src/folding_ranges.rs @@ -572,6 +572,8 @@ fn foo()-> ( bool, bool, ) { (true, true) } + +fn bar() -> (bool, bool) { (true, true) } "#, ) } -- cgit v1.2.3