File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
crates/ide_assists/src/handlers Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,10 @@ pub(crate) fn generate_documentation_template(
41
41
) -> Option < ( ) > {
42
42
let name = ctx. find_node_at_offset :: < ast:: Name > ( ) ?;
43
43
let ast_func = name. syntax ( ) . parent ( ) . and_then ( ast:: Fn :: cast) ?;
44
- if is_in_trait_impl ( & ast_func) || !is_public ( & ast_func) {
44
+ if is_in_trait_impl ( & ast_func)
45
+ || !is_public ( & ast_func)
46
+ || ast_func. doc_comments ( ) . next ( ) . is_some ( )
47
+ {
45
48
return None ;
46
49
}
47
50
@@ -70,9 +73,6 @@ pub(crate) fn generate_documentation_template(
70
73
doc_lines. append ( & mut lines) ;
71
74
}
72
75
}
73
- if ast_func. doc_comments ( ) . next ( ) . is_some ( ) {
74
- doc_lines. push ( "--- OLD VERSION BELOW ---" . into ( ) ) ;
75
- }
76
76
builder. insert ( text_range. start ( ) , documentation_from_lines ( doc_lines, indent_level) ) ;
77
77
} ,
78
78
)
@@ -501,6 +501,17 @@ mod ParentPrivateModule {
501
501
) ;
502
502
}
503
503
504
+ #[ test]
505
+ fn not_applicable_if_function_already_documented ( ) {
506
+ check_assist_not_applicable (
507
+ generate_documentation_template,
508
+ r#"
509
+ /// Some documentation here
510
+ pub fn $0documented_function() {}
511
+ "# ,
512
+ ) ;
513
+ }
514
+
504
515
#[ test]
505
516
fn supports_noop_function ( ) {
506
517
check_assist (
You can’t perform that action at this time.
0 commit comments