Merge pull request #20302 from Young-Flash/fix_20240
Some checks are pending
metrics / build_metrics (push) Waiting to run
metrics / other_metrics (diesel-1.4.8) (push) Blocked by required conditions
metrics / other_metrics (hyper-0.14.18) (push) Blocked by required conditions
metrics / other_metrics (ripgrep-13.0.0) (push) Blocked by required conditions
metrics / other_metrics (self) (push) Blocked by required conditions
metrics / other_metrics (webrender-2022) (push) Blocked by required conditions
metrics / generate_final_metrics (push) Blocked by required conditions
rustdoc / rustdoc (push) Waiting to run

fix fold doc comment for multiline param list fn
This commit is contained in:
Laurențiu Nicola 2025-07-27 06:01:44 +00:00 committed by GitHub
commit 7a621817af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -73,11 +73,13 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> {
}
if fn_node.body().is_some() {
// Get the actual start of the function (excluding doc comments)
let fn_start = fn_node
.fn_token()
.map(|token| token.text_range().start())
.unwrap_or(node.text_range().start());
res.push(Fold {
range: TextRange::new(
node.text_range().start(),
node.text_range().end(),
),
range: TextRange::new(fn_start, node.text_range().end()),
kind: FoldKind::Function,
});
continue;
@ -688,4 +690,21 @@ type Foo<T, U> = foo<fold arglist><
"#,
)
}
#[test]
fn test_fold_doc_comments_with_multiline_paramlist_function() {
check(
r#"
<fold comment>/// A very very very very very very very very very very very very very very very
/// very very very long description</fold>
<fold function>fn foo<fold arglist>(
very_long_parameter_name: u32,
another_very_long_parameter_name: u32,
third_very_long_param: u32,
)</fold> <fold block>{
todo!()
}</fold></fold>
"#,
);
}
}