fix(jsonview): avoid width underflow in static string rendering - #117
fix(jsonview): avoid width underflow in static string rendering#117sylvesterkaczmarek wants to merge 1 commit into
Conversation
Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Summary
Avoid converting a negative remaining display width into an enormous unsigned truncation limit when rendering static JSON strings in narrow terminals.
Problem
formatResultcurrently truncates long strings with:Object and array rendering can pass a non-positive
widthafter subtracting the rendered key or numbering width. Convertingwidth-1touintthen wraps the negative value to a very large number, so the string is effectively not truncated and can spill far beyond the available terminal width.Fix
Centralize string-width handling in a small helper that:
uint.Normal-width output is unchanged.
Regression coverage
Added focused tests covering:
Validation
The branch is based directly on current upstream
main(ee92673a416c0851a5fe8907a2453db7bd450633) and contains one signed commit touching only the static JSON renderer and its focused regression test. Full Go test execution is left to repository CI.Risk
Low. The behavior change is limited to string values whose available display width is zero or too small to contain the original value.