@@ -473,10 +473,13 @@ impl JsdocFormatter<'_, '_> {
473473 }
474474
475475 // Split description into first line and rest (avoids collecting all lines)
476- let ( first_text_line , rest_of_desc) = match desc_raw. split_once ( '\n' ) {
477- Some ( ( first, rest) ) => ( first. trim ( ) , Some ( rest) ) ,
478- None => ( desc_raw. trim ( ) , None ) ,
476+ let ( first_line , rest_of_desc) = match desc_raw. split_once ( '\n' ) {
477+ Some ( ( first, rest) ) => ( first, Some ( rest) ) ,
478+ None => ( desc_raw, None ) ,
479479 } ;
480+ let first_text_line = first_line. trim ( ) ;
481+ // Keep a Markdown hard line break, which `trim()` drops
482+ let first_hard_break = rest_of_desc. is_some ( ) && first_line. ends_with ( " " ) ;
480483
481484 // If the description starts with a code fence, output the tag line alone
482485 // and treat the entire description as structural content with a blank line separator
@@ -626,6 +629,9 @@ impl JsdocFormatter<'_, '_> {
626629 let mut s = if has_remaining {
627630 let mut s = String :: with_capacity ( first_text. len ( ) + 1 + remaining_desc. len ( ) ) ;
628631 s. push_str ( & first_text) ;
632+ if first_hard_break {
633+ s. push_str ( " " ) ;
634+ }
629635 s. push ( '\n' ) ;
630636 s. push_str ( & remaining_desc) ;
631637 s
@@ -1130,8 +1136,11 @@ impl JsdocFormatter<'_, '_> {
11301136 }
11311137
11321138 let fits_on_one_line = prefix_len + str_width ( & desc_text) <= self . wrap_width ;
1133- if fits_on_one_line || skip_wrapping {
1134- // Fits on one line, or tag skips description formatting (no wrapping).
1139+ // Other descriptions go through wrapping, which collapses line breaks and spaces
1140+ let is_plain_one_liner =
1141+ fits_on_one_line && !desc_text. contains ( '\n' ) && !desc_text. contains ( " " ) ;
1142+ if is_plain_one_liner || skip_wrapping {
1143+ // Fits on one line as is, or tag skips description formatting (no wrapping).
11351144 // Tags in TAGS_PEV_FORMATE_DESCRIPTION (e.g. @see) and unknown tags
11361145 // keep their description on one line regardless of length.
11371146 // When desc has embedded newlines (e.g. @module Name\n\nMore text),
0 commit comments