File tree Expand file tree Collapse file tree 1 file changed +23
-4
lines changed
src/tools/rust-analyzer/crates/ide/src Expand file tree Collapse file tree 1 file changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -73,11 +73,13 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> {
7373 }
7474
7575 if fn_node. body ( ) . is_some ( ) {
76+ // Get the actual start of the function (excluding doc comments)
77+ let fn_start = fn_node
78+ . fn_token ( )
79+ . map ( |token| token. text_range ( ) . start ( ) )
80+ . unwrap_or ( node. text_range ( ) . start ( ) ) ;
7681 res. push ( Fold {
77- range : TextRange :: new (
78- node. text_range ( ) . start ( ) ,
79- node. text_range ( ) . end ( ) ,
80- ) ,
82+ range : TextRange :: new ( fn_start, node. text_range ( ) . end ( ) ) ,
8183 kind : FoldKind :: Function ,
8284 } ) ;
8385 continue ;
@@ -688,4 +690,21 @@ type Foo<T, U> = foo<fold arglist><
688690"# ,
689691 )
690692 }
693+
694+ #[ test]
695+ fn test_fold_doc_comments_with_multiline_paramlist_function ( ) {
696+ check (
697+ r#"
698+ <fold comment>/// A very very very very very very very very very very very very very very very
699+ /// very very very long description</fold>
700+ <fold function>fn foo<fold arglist>(
701+ very_long_parameter_name: u32,
702+ another_very_long_parameter_name: u32,
703+ third_very_long_param: u32,
704+ )</fold> <fold block>{
705+ todo!()
706+ }</fold></fold>
707+ "# ,
708+ ) ;
709+ }
691710}
You can’t perform that action at this time.
0 commit comments