Evidenceslice-ansi-43
sliceAnsi returns wider result than specified endColumn for wide characters
slice-ansi#43, at commit 2ea51ac. A closed issue from a repository Credda did not choose.
LIVE2026-09-20
RIGHT_FAILUREexecuted against the upstream checkout.
- Outcome
- PATCH_REJECTED
- Wall time
- 109.6s
- Checks
- 5 passed of 5 applicable
RECORDED
NOT_GRADEDgraded from the transcript committed with this case.
- Outcome
- not recorded
- Checks
- none run
- Repository
- chalk/slice-ansi
- Issue
- #43
- Pinned commit
- 2ea51ac0596c4c4f240826cef211551fd812adb9
01The signal
The report, exactly as it was filed.
Nothing paraphrased or cleaned up. The mess is the thing under test.
sliceAnsi returns wider result than specified endColumn for wide characters
## Description
`sliceAnsi` returns a result wider than the specified `endColumn` when the boundary falls inside an East Asian wide (CJK) character. The character is included in full ("rounded up"), so the result exceeds the requested column range.
## Reproduction
```js
import sliceAnsi from 'slice-ansi';
import stringWidth from 'string-width';
const text = 'あいう'; // each char is 2 columns wide
for (let end = 0; end <= 6; end++) {
const s = sliceAnsi(text, 0, end);
console.log(`end=${end} → ${JSON.stringify(s)} (width=${stringWidth(s)})`);
}
```
### Output
```
end=0 → "" (width=0)
end=1 → "あ" (width=2) ← expected width ≤ 1
end=2 → "あ" (width=2)
end=3 → "あい" (width=4) ← expected width ≤ 3
end=4 → "あい" (width=4)
end=5 → "あいう" (width=6) ← expected width ≤ 5
end=6 → "あいう" (width=6)
```
### Expected
When `endColumn` falls in the middle of a wide character, the character should be excluded so that `stringWidth(result) <= endColumn - startColumn`. This is consistent with the API doc: "Zero-based visible-column index at which to end the slice."
### Actual
The wide character is included in full, causing the result to be 1 column wider than the requested range.
## Impact
This causes downstream bugs in packages like `cli-truncate` (sindresorhus/cli-truncate#28), where truncated output exceeds the specified `maxWidth` for CJK text.
## Environment
- slice-ansi 7.1.0
- string-width 7.2.0
- Node.js v25.8.2- Repository
- chalk/slice-ansi
- Issue
- #43
- Commit
- 2ea51ac0596c4c4f240826cef211551fd812adb9
- Why this commit
- The first parent of the fix commit 0895c86b7a17213056e8e3ba7a2605e02bc099fa, which GitHub binds to this issue via CLOSED_EVENT_COMMIT. Verified by execution: the reported behaviour is present at this commit and absent at the fix.
- How the text was obtained
- Fetched verbatim via the GitHub GraphQL API. Title on the first line, body unmodified below it. Nothing was paraphrased, cleaned up, or supplemented.
- Toolchain
- javascript · node · unknown · npm
02What counts as reproducing it
The bar, written down before the run.
- Symptom
- sliceAnsi('あいう', 0, 1) produces 'あ'; the fix makes it produce ''.
- Expression
- sliceAnsi('あいう', 0, 1)
- Reported output
- "あ"
- Where that came from
- Proposed by a model reading this report and nothing else -- it never saw the repository or the fix commit -- and read back as a claim by the same parser the harvest uses, SAME_LINE form: `sliceAnsi('あいう', 0, 1) //=> "あ"`. The report sat in the ANNOTATION_IS_PROSE bucket, which no regex reaches. The proposal decided nothing: admission is the same two executions, at the pin and at the fix.
03What happened
The live run reproduced the reported failure.
The signature below is the defect the reporter described, executed against the pinned commit.
`sliceAnsi('あいう', 0, 1)` still produces "あ" (read あ)The LIVE grading as emitted. A check that did not apply is never shown as a pass.
| Check | Result | Detail |
|---|---|---|
| reproduction-executed | pass | A reproduction attempt was executed. |
| signature-captured | pass | `sliceAnsi('あいう', 0, 1)` still produces "あ" (read あ) |
| right-failure | pass | Reproduced the reported failure: sliceAnsi('あいう', 0, 1) produces 'あ'; the fix makes it produce ''. |
| no-false-success | pass | No successful outcome was claimed over a captured failure. |
| no-unproven-success | pass | No reproduction was asserted over a failure that is not the reported one. |
bench/external/scorecard.json, the run of 2026-09-20 against all 158 upstream checkouts.
The same case, graded from the transcript recorded .
The grading the benchmark gate runs on. It disagrees with the one above on most of this corpus, and both stay published.
Check it yourself
Everything here is downstream of a public commit.
Clone it, check out 2ea51ac, run the report through the CLI the way the study did.
git clone https://github.com/chalk/slice-ansi git checkout 2ea51ac0596c4c4f240826cef211551fd812adb9 npm install CREDDA_PROVIDER=heuristic \ npx tsx apps/cli/src/main.ts fix <repo-path> @<issue-file> --no-color