Skip to content

Conversation

@ChrisDryden
Copy link
Contributor

Been looking at how I can contribute to getting some of the tests to pass, working on this bin and it seems like adding this is a simple fix for the main fold test. The handling zero tests seem like they require a relatively major rework

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 19, 2025

CodSpeed Performance Report

Merging #9328 will degrade performances by 2.81%

Comparing ChrisDryden:main (01c25b6) with main (15d22c2)

Summary

❌ 2 regressions
✅ 124 untouched
⏩ 6 skipped1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
fold_custom_width[50000] 32.1 ms 32.9 ms -2.31%
fold_many_lines[100000] 77.8 ms 80.1 ms -2.81%

Footnotes

  1. 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/fold/fold is no longer failing!

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/fold/fold is no longer failing!

Comment on lines 437 to 447
let mut next_idx = iter.peek().map(|(idx, _)| *idx).unwrap_or(line_bytes.len());

// Include combining characters with the base character
while let Some(&(_, next_ch)) = iter.peek() {
if unicode_width::UnicodeWidthChar::width(next_ch).unwrap_or(1) == 0 {
iter.next();
next_idx = iter.peek().map(|(idx, _)| *idx).unwrap_or(line_bytes.len());
} else {
break;
}
}
Copy link
Contributor

@cakebaker cakebaker Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can set next_idx after the loop as you don't use it in the loop.

Suggested change
let mut next_idx = iter.peek().map(|(idx, _)| *idx).unwrap_or(line_bytes.len());
// Include combining characters with the base character
while let Some(&(_, next_ch)) = iter.peek() {
if unicode_width::UnicodeWidthChar::width(next_ch).unwrap_or(1) == 0 {
iter.next();
next_idx = iter.peek().map(|(idx, _)| *idx).unwrap_or(line_bytes.len());
} else {
break;
}
}
// Include combining characters with the base character
while let Some(&(_, next_ch)) = iter.peek() {
if unicode_width::UnicodeWidthChar::width(next_ch).unwrap_or(1) == 0 {
iter.next();
} else {
break;
}
}
let next_idx = iter.peek().map(|(idx, _)| *idx).unwrap_or(line_bytes.len());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much cleaner, thanks!

Copy link
Contributor

@cakebaker cakebaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if you have seen it: the CI shows some trivial clippy issues.

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/fold/fold is no longer failing!

@ChrisDryden ChrisDryden changed the title Adding combining character support for fold Fold: Adding combining character support Nov 19, 2025
@cakebaker cakebaker merged commit 2a314c7 into uutils:main Nov 20, 2025
126 of 127 checks passed
@cakebaker
Copy link
Contributor

Congrats! The gnu test tests/fold/fold is no longer failing!

Kudos, and thanks for your PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants