Skip to content

Commit d287669

Browse files
CopilotDunqing
andcommitted
Address review feedback: add example, remove unnecessary comments and test files
Co-authored-by: Dunqing <29533304+Dunqing@users.noreply.github.com>
1 parent 7a65b99 commit d287669

File tree

4 files changed

+5
-121
lines changed

4 files changed

+5
-121
lines changed
-6.32 KB
Binary file not shown.

crates/oxc_codegen/examples/test_crlf.rs

Lines changed: 0 additions & 52 deletions
This file was deleted.

crates/oxc_codegen/src/comment.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
1419
struct 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');

napi/transform/test/crlf.test.ts

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)