@@ -11,6 +11,11 @@ pub type CommentsMap = FxHashMap</* attached_to */ u32, Vec<Comment>>;
1111
1212/// Custom iterator that splits text on line terminators while handling CRLF as a single unit.
1313/// This avoids creating empty strings between CR and LF characters.
14+ ///
15+ /// # Example
16+ /// Standard split would turn "line1\r\nline2" into ["line1", "", "line2"] because
17+ /// it treats \r and \n as separate terminators. This iterator correctly produces
18+ /// ["line1", "line2"] by treating \r\n as a single terminator.
1419struct LineTerminatorSplitter < ' a > {
1520 text : & ' a str ,
1621 position : usize ,
@@ -177,8 +182,6 @@ impl Codegen<'_> {
177182 self . print_str_escaping_script_close_tag ( comment_source) ;
178183 }
179184 CommentKind :: Block => {
180- // Print block comments with our own indentation.
181- // Use custom splitter to handle CRLF correctly without allocations
182185 for line in LineTerminatorSplitter :: new ( comment_source) {
183186 if !line. starts_with ( "/*" ) {
184187 self . print_indent ( ) ;
@@ -213,7 +216,6 @@ impl Codegen<'_> {
213216 if comment. is_block ( ) && text. contains ( is_line_terminator) {
214217 let mut buffer = String :: with_capacity ( text. len ( ) ) ;
215218 // Print block comments with our own indentation.
216- // Use custom splitter to handle CRLF correctly without extra allocations in the splitting logic
217219 for line in LineTerminatorSplitter :: new ( & text) {
218220 if !line. starts_with ( "/*" ) {
219221 buffer. push ( '\t' ) ;
0 commit comments