Skip to content

fix: use terminal encoding instead of default charset in VirtualTerminal (fixes #1821)#1822

Merged
gnodet merged 1 commit into
jline:masterfrom
gnodet:ci-issue-1821
Apr 23, 2026
Merged

fix: use terminal encoding instead of default charset in VirtualTerminal (fixes #1821)#1822
gnodet merged 1 commit into
jline:masterfrom
gnodet:ci-issue-1821

Conversation

@gnodet
Copy link
Copy Markdown
Member

@gnodet gnodet commented Apr 23, 2026

The MasterOutputStream in VirtualTerminal used Charset.defaultCharset() to decode terminal output bytes. On Windows, the default charset is typically Windows-1252, not UTF-8. This caused multi-byte UTF-8 characters like the ellipsis (, U+2026) used by Status for line truncation to be decoded incorrectly, producing garbled output and failing the testStatusLineTruncation assertion.

The fix uses encoding() (inherited from AbstractTerminal) which returns the charset explicitly passed to the terminal constructor — StandardCharsets.UTF_8 in the tests.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected character encoding handling to use terminal's configured encoding rather than system defaults, improving compatibility with custom terminal configurations.

…nal (fixes jline#1821)

The MasterOutputStream in VirtualTerminal used Charset.defaultCharset() to
decode bytes, which on Windows is typically Windows-1252 instead of UTF-8.
This caused multi-byte UTF-8 characters like the ellipsis (U+2026) to be
garbled, making StatusTest.testStatusLineTruncation fail on Windows.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 118d1668-7882-4227-828d-6eecd1ed629f

📥 Commits

Reviewing files that changed from the base of the PR and between 6561762 and e001751.

📒 Files selected for processing (1)
  • terminal/src/test/java/org/jline/utils/DisplayTest.java

📝 Walkthrough

Walkthrough

The MasterOutputStream's CharsetDecoder initialization in the test file was updated to use the VirtualTerminal's configured encoding instead of the JVM's default charset. Error handling behavior remains unchanged.

Changes

Cohort / File(s) Summary
CharsetDecoder Source Update
terminal/src/test/java/org/jline/utils/DisplayTest.java
Changed CharsetDecoder initialization to use VirtualTerminal's configured encoding() instead of Charset.defaultCharset() for character decoding.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A tiny tweak, so neat and small,
Terminal encoding rules them all!
From default charset we did part,
Now VirtualTerminal steals the heart.
One line changed, yet semantics shine! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: switching from default charset to terminal encoding in VirtualTerminal, and references the related issue (#1821).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link
Copy Markdown

@gnodet gnodet merged commit 38510ed into jline:master Apr 23, 2026
15 checks passed
gnodet added a commit that referenced this pull request Apr 27, 2026
…nal (fixes #1821) (#1822)

The MasterOutputStream in VirtualTerminal used Charset.defaultCharset() to
decode bytes, which on Windows is typically Windows-1252 instead of UTF-8.
This caused multi-byte UTF-8 characters like the ellipsis (U+2026) to be
garbled, making StatusTest.testStatusLineTruncation fail on Windows.
@gnodet gnodet added the fix Bug fix label May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant