Skip to content

Commit 94fcf52

Browse files
committed
fix(comment): Prefer light_rewrite_comment if it is not a doccomment
1 parent b2da8a5 commit 94fcf52

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Diff for: src/comment.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -362,12 +362,18 @@ fn identify_comment(
362362
};
363363

364364
let (first_group, rest) = orig.split_at(first_group_ending);
365+
366+
let is_doc_comment_with_our_determination = is_doc_comment || style.is_doc_comment();
365367
let rewritten_first_group =
366368
if !config.normalize_comments() && has_bare_lines && style.is_block_comment() {
367369
trim_left_preserve_layout(first_group, shape.indent, config)?
368370
} else if !config.normalize_comments()
369371
&& !config.wrap_comments()
370-
&& !config.format_code_in_doc_comments()
372+
&& !(
373+
// `format_code_in_doc_comments` should only take effect on doc comments,
374+
// so we only consider it when this comment block is a doc comment block.
375+
is_doc_comment_with_our_determination && config.format_code_in_doc_comments()
376+
)
371377
{
372378
light_rewrite_comment(first_group, shape.indent, config, is_doc_comment)
373379
} else {
@@ -377,7 +383,7 @@ fn identify_comment(
377383
style,
378384
shape,
379385
config,
380-
is_doc_comment || style.is_doc_comment(),
386+
is_doc_comment_with_our_determination,
381387
)?
382388
};
383389
if rest.is_empty() {

0 commit comments

Comments
 (0)