aboutsummaryrefslogtreecommitdiff
path: root/crates/ide
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide')
-rw-r--r--crates/ide/src/annotations.rs34
-rwxr-xr-xcrates/ide/src/folding_ranges.rs17
2 files changed, 34 insertions, 17 deletions
diff --git a/crates/ide/src/annotations.rs b/crates/ide/src/annotations.rs
index b0c4ed60a..8d68dce05 100644
--- a/crates/ide/src/annotations.rs
+++ b/crates/ide/src/annotations.rs
@@ -58,7 +58,7 @@ pub(crate) fn annotations(
58 } 58 }
59 59
60 let action = runnable.action(); 60 let action = runnable.action();
61 let range = runnable.nav.full_range; 61 let range = runnable.nav.focus_or_full_range();
62 62
63 if config.run { 63 if config.run {
64 annotations.push(Annotation { 64 annotations.push(Annotation {
@@ -224,7 +224,7 @@ fn main() {
224 expect![[r#" 224 expect![[r#"
225 [ 225 [
226 Annotation { 226 Annotation {
227 range: 50..85, 227 range: 53..57,
228 kind: Runnable { 228 kind: Runnable {
229 debug: false, 229 debug: false,
230 runnable: Runnable { 230 runnable: Runnable {
@@ -243,7 +243,7 @@ fn main() {
243 }, 243 },
244 }, 244 },
245 Annotation { 245 Annotation {
246 range: 50..85, 246 range: 53..57,
247 kind: Runnable { 247 kind: Runnable {
248 debug: true, 248 debug: true,
249 runnable: Runnable { 249 runnable: Runnable {
@@ -328,7 +328,7 @@ fn main() {
328 expect![[r#" 328 expect![[r#"
329 [ 329 [
330 Annotation { 330 Annotation {
331 range: 14..48, 331 range: 17..21,
332 kind: Runnable { 332 kind: Runnable {
333 debug: false, 333 debug: false,
334 runnable: Runnable { 334 runnable: Runnable {
@@ -347,7 +347,7 @@ fn main() {
347 }, 347 },
348 }, 348 },
349 Annotation { 349 Annotation {
350 range: 14..48, 350 range: 17..21,
351 kind: Runnable { 351 kind: Runnable {
352 debug: true, 352 debug: true,
353 runnable: Runnable { 353 runnable: Runnable {
@@ -436,7 +436,7 @@ fn main() {
436 expect![[r#" 436 expect![[r#"
437 [ 437 [
438 Annotation { 438 Annotation {
439 range: 66..100, 439 range: 69..73,
440 kind: Runnable { 440 kind: Runnable {
441 debug: false, 441 debug: false,
442 runnable: Runnable { 442 runnable: Runnable {
@@ -455,7 +455,7 @@ fn main() {
455 }, 455 },
456 }, 456 },
457 Annotation { 457 Annotation {
458 range: 66..100, 458 range: 69..73,
459 kind: Runnable { 459 kind: Runnable {
460 debug: true, 460 debug: true,
461 runnable: Runnable { 461 runnable: Runnable {
@@ -597,7 +597,7 @@ fn main() {}
597 expect![[r#" 597 expect![[r#"
598 [ 598 [
599 Annotation { 599 Annotation {
600 range: 0..12, 600 range: 3..7,
601 kind: Runnable { 601 kind: Runnable {
602 debug: false, 602 debug: false,
603 runnable: Runnable { 603 runnable: Runnable {
@@ -616,7 +616,7 @@ fn main() {}
616 }, 616 },
617 }, 617 },
618 Annotation { 618 Annotation {
619 range: 0..12, 619 range: 3..7,
620 kind: Runnable { 620 kind: Runnable {
621 debug: true, 621 debug: true,
622 runnable: Runnable { 622 runnable: Runnable {
@@ -670,7 +670,7 @@ fn main() {
670 expect![[r#" 670 expect![[r#"
671 [ 671 [
672 Annotation { 672 Annotation {
673 range: 58..95, 673 range: 61..65,
674 kind: Runnable { 674 kind: Runnable {
675 debug: false, 675 debug: false,
676 runnable: Runnable { 676 runnable: Runnable {
@@ -689,7 +689,7 @@ fn main() {
689 }, 689 },
690 }, 690 },
691 Annotation { 691 Annotation {
692 range: 58..95, 692 range: 61..65,
693 kind: Runnable { 693 kind: Runnable {
694 debug: true, 694 debug: true,
695 runnable: Runnable { 695 runnable: Runnable {
@@ -812,7 +812,7 @@ mod tests {
812 expect![[r#" 812 expect![[r#"
813 [ 813 [
814 Annotation { 814 Annotation {
815 range: 0..12, 815 range: 3..7,
816 kind: Runnable { 816 kind: Runnable {
817 debug: false, 817 debug: false,
818 runnable: Runnable { 818 runnable: Runnable {
@@ -831,7 +831,7 @@ mod tests {
831 }, 831 },
832 }, 832 },
833 Annotation { 833 Annotation {
834 range: 0..12, 834 range: 3..7,
835 kind: Runnable { 835 kind: Runnable {
836 debug: true, 836 debug: true,
837 runnable: Runnable { 837 runnable: Runnable {
@@ -850,7 +850,7 @@ mod tests {
850 }, 850 },
851 }, 851 },
852 Annotation { 852 Annotation {
853 range: 14..64, 853 range: 18..23,
854 kind: Runnable { 854 kind: Runnable {
855 debug: false, 855 debug: false,
856 runnable: Runnable { 856 runnable: Runnable {
@@ -871,7 +871,7 @@ mod tests {
871 }, 871 },
872 }, 872 },
873 Annotation { 873 Annotation {
874 range: 14..64, 874 range: 18..23,
875 kind: Runnable { 875 kind: Runnable {
876 debug: true, 876 debug: true,
877 runnable: Runnable { 877 runnable: Runnable {
@@ -892,7 +892,7 @@ mod tests {
892 }, 892 },
893 }, 893 },
894 Annotation { 894 Annotation {
895 range: 30..62, 895 range: 45..57,
896 kind: Runnable { 896 kind: Runnable {
897 debug: false, 897 debug: false,
898 runnable: Runnable { 898 runnable: Runnable {
@@ -918,7 +918,7 @@ mod tests {
918 }, 918 },
919 }, 919 },
920 Annotation { 920 Annotation {
921 range: 30..62, 921 range: 45..57,
922 kind: Runnable { 922 kind: Runnable {
923 debug: true, 923 debug: true,
924 runnable: Runnable { 924 runnable: Runnable {
diff --git a/crates/ide/src/folding_ranges.rs b/crates/ide/src/folding_ranges.rs
index b893c1c54..c5015a345 100755
--- a/crates/ide/src/folding_ranges.rs
+++ b/crates/ide/src/folding_ranges.rs
@@ -19,6 +19,7 @@ pub enum FoldKind {
19 Statics, 19 Statics,
20 Array, 20 Array,
21 WhereClause, 21 WhereClause,
22 ReturnType,
22} 23}
23 24
24#[derive(Debug)] 25#[derive(Debug)]
@@ -131,6 +132,7 @@ fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> {
131 COMMENT => Some(FoldKind::Comment), 132 COMMENT => Some(FoldKind::Comment),
132 ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList), 133 ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList),
133 ARRAY_EXPR => Some(FoldKind::Array), 134 ARRAY_EXPR => Some(FoldKind::Array),
135 RET_TYPE => Some(FoldKind::ReturnType),
134 ASSOC_ITEM_LIST 136 ASSOC_ITEM_LIST
135 | RECORD_FIELD_LIST 137 | RECORD_FIELD_LIST
136 | RECORD_PAT_FIELD_LIST 138 | RECORD_PAT_FIELD_LIST
@@ -300,6 +302,7 @@ mod tests {
300 FoldKind::Statics => "statics", 302 FoldKind::Statics => "statics",
301 FoldKind::Array => "array", 303 FoldKind::Array => "array",
302 FoldKind::WhereClause => "whereclause", 304 FoldKind::WhereClause => "whereclause",
305 FoldKind::ReturnType => "returntype",
303 }; 306 };
304 assert_eq!(kind, &attr.unwrap()); 307 assert_eq!(kind, &attr.unwrap());
305 } 308 }
@@ -560,4 +563,18 @@ where
560"#, 563"#,
561 ) 564 )
562 } 565 }
566
567 #[test]
568 fn fold_return_type() {
569 check(
570 r#"
571fn foo()<fold returntype>-> (
572 bool,
573 bool,
574)</fold> { (true, true) }
575
576fn bar() -> (bool, bool) { (true, true) }
577 "#,
578 )
579 }
563} 580}