Skip to content

Inconsistent trailing space handling in wrap_preserving_code function #66

@coderabbitai

Description

@coderabbitai

Description

There is an inconsistency in the wrap_preserving_code function in src/lib.rs around lines 319-322. The final flush operation trims trailing spaces using trim_end(), while the earlier loop behavior does not trim trailing spaces.

Current Code

let trimmed = current.trim_end();
if !trimmed.is_empty() {
    lines.push(trimmed.to_string());
}

Expected Behavior

The final flush should mirror the earlier loop behavior by not trimming trailing spaces:

if !current.is_empty() {
    lines.push(current);
}

Impact

This inconsistency could lead to different handling of trailing spaces at line boundaries, potentially affecting the preservation of whitespace in wrapped text.

References

Reported by: leynos

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions