Skip to content

Add hard wrap limit option to console#2494

Open
trancexpress wants to merge 1 commit intoeclipse-platform:masterfrom
trancexpress:gh2479
Open

Add hard wrap limit option to console#2494
trancexpress wants to merge 1 commit intoeclipse-platform:masterfrom
trancexpress:gh2479

Conversation

@trancexpress
Copy link
Copy Markdown
Contributor

@trancexpress trancexpress commented Mar 1, 2026

Add hard wrap limit option to console

This change adds the following options to org.eclipse.debug.ui:

  • Console.limitLongLines (boolean)
  • Console.limitLongLinesWrap (boolean)
  • Console.limitLongLinesLength (int)

When limitLongLines is set, long console lines will be trimmed or wrapped.
If limitLongLinesWrap is set, lines are wrapped. Otherwise lines are trimmed.
The length at which long lines are trimmed/wrapped is limitLongLinesLength.

The preferences apply to output before its appended to the
console document. In contrast, the existing console word wrapping is applied
after the output is appended to the console document.

Fixes: #2479

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 1, 2026

Test Results

    54 files  ±  0      54 suites  ±0   36m 40s ⏱️ +40s
 4 646 tests + 88   4 623 ✅ + 89   23 💤 ±0  0 ❌  - 1 
12 402 runs  +132  12 243 ✅ +133  159 💤 ±0  0 ❌  - 1 

Results for commit 117fa34. ± Comparison against base commit 0eda9f4.

♻️ This comment has been updated with latest results.

@trancexpress trancexpress force-pushed the gh2479 branch 3 times, most recently from 4e4ac26 to 34508dc Compare April 11, 2026 12:26
This change adds the following options to org.eclipse.debug.ui:

* Console.limitLongLines (boolean)
* Console.limitLongLinesWrap (boolean)
* Console.limitLongLinesLength (int)

When limitLongLines is set, long console lines will be trimmed or wrapped.
If limitLongLinesWrap is set, lines are wrapped. Otherwise lines are trimmed.
The length at which long lines are trimmed/wrapped is limitLongLinesLength.

The preferences apply to output before its appended to the
console document. In contrast, the existing console word wrapping is applied
after the output is appended to the console document.

Fixes: eclipse-platform#2479
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new “hard” long-line limiting feature for Eclipse consoles, allowing console output to be wrapped or truncated before it is appended to the console document (aimed at preventing UI freezes from extremely long lines).

Changes:

  • Introduces long-line output modifiers (wrap/truncate) and hooks them into IOConsolePartitioner/IOConsole.
  • Adds Debug UI preferences + preference page controls and propagates changes into ProcessConsole.
  • Adds unit/integration tests for wrapping/truncation behavior and includes them in the automated test suite.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java Applies long-line wrapping/truncation to pending output before document append.
debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IConsoleOutputModifier.java New internal interface for chunk-based output modification.
debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleOutputLineWrap.java Implements chunk-aware hard wrapping at a fixed character limit.
debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleOutputLineTruncate.java Implements chunk-aware truncation with ellipsis at a fixed character limit.
debug/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java Exposes a new public API to configure long-line limiting.
debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java Wires Debug UI preferences into the console’s new line-limit API.
debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java Adds new preference keys for long-line limiting.
debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties Adds UI strings for the new preference controls.
debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java Adds NLS fields for the new UI strings.
debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ConsolePreferencePage.java Adds preference UI controls (enable, wrap vs truncate, length).
debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java Provides default values for the new preferences.
debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleTests.java Adds integration tests verifying line wrap/truncate in the IOConsole pipeline.
debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleOutputLineWrapTest.java Adds parameterized unit tests for wrapping logic across chunk boundaries.
debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleOutputLineTruncateTest.java Adds parameterized unit tests for truncation logic across chunk boundaries.
debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java Registers the new unit tests in the automated suite.
debug/org.eclipse.debug.tests/META-INF/MANIFEST.MF Adds required JUnit params provider import for the new parameterized tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +842 to +845
int lineLimit = lineLengthLimit;
if (lineLimit > 0) {
IConsoleOutputModifier modifier = lineLimitWrap ? lineBreak : truncate;
List<PendingPartition> modified = new ArrayList<>(pendingCopy.size());
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

pendingSize (and sizeHint) are computed before applying the long-line modifier, but the modifier can change the total character count (wrapping increases it; truncation decreases it). This makes the subsequent highWaterMark trimming decision use stale sizes, which can lead to trimming too much/too little and can defeat the purpose of preventing huge UI updates. Recompute pendingSize/sizeHint after pendingCopy is replaced, or move the size calculation to after modification.

Copilot uses AI. Check for mistakes.
Comment on lines +298 to +299
* @param length length at which to wrap or truncate lines, negative to disable
* @param wrap whether to wrap the line or truncate line limit
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

Javadoc parameter descriptions are out of order: the method signature is (boolean wrap, int length) but the tags describe length first and wrap second. Please reorder/fix the @param entries so callers don’t misread which argument is which.

Suggested change
* @param length length at which to wrap or truncate lines, negative to disable
* @param wrap whether to wrap the line or truncate line limit
* @param wrap whether to wrap the line or truncate line limit
* @param length length at which to wrap or truncate lines, negative to disable

Copilot uses AI. Check for mistakes.
Comment on lines +41 to +44
public CharSequence modify(CharSequence t, int lineLimit) {
StringBuilder text = new StringBuilder(t);
int currentNewline = text.indexOf(nl);
int start = 0;
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

modify() only searches for the platform line separator (nl) via indexOf(nl). Console output can contain any legal line delimiter (e.g. \n even on Windows, or bare \r), and the surrounding console code explicitly supports multiple delimiters. As-is, lines containing non-nl delimiters won’t reset currentLineLength, so wrapping may be applied across line boundaries and/or injected delimiters may be inconsistent. Consider handling all common delimiters (\r\n, \n, \r) or passing in the document’s legal delimiters/matcher.

Copilot uses AI. Check for mistakes.
Comment on lines +41 to +45
@Override
public CharSequence modify(CharSequence t, int lineLimit) {
StringBuilder text = new StringBuilder(t);
int currentNewline = text.indexOf(nl);
int start = 0;
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

modify() only detects newlines using the platform line separator (nl). Since console output can include other legal line delimiters (\n, \r, \r\n), truncation may treat them as regular characters, causing line-length state to carry over incorrectly and potentially truncating/wiping content across actual line boundaries. Consider recognizing all common delimiters (or using the document’s legal delimiters) when scanning chunks.

Copilot uses AI. Check for mistakes.
Comment on lines +258 to +263
* non-negative, lines are wrapped or truncated at this length.
*
* @param wrap {@code true} if the line should be wrapped, {@code false} if it
* should be truncated. No effect if {@code length} is negative.
* @param length The length at which lines are wrapped or truncated. Negative if
* the line should be left unchanged.
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

The Javadoc says the length limit is applied when it is “non-negative”, but the partitioner currently only applies long-line handling when length > 0. Either update the contract to say “positive” (and/or validate/reject 0), or make the implementation consistently handle a 0 value.

Suggested change
* non-negative, lines are wrapped or truncated at this length.
*
* @param wrap {@code true} if the line should be wrapped, {@code false} if it
* should be truncated. No effect if {@code length} is negative.
* @param length The length at which lines are wrapped or truncated. Negative if
* the line should be left unchanged.
* positive, lines are wrapped or truncated at this length.
*
* @param wrap {@code true} if the line should be wrapped, {@code false} if it
* should be truncated. No effect if {@code length} is not positive.
* @param length The length at which lines are wrapped or truncated. Non-positive
* if the line should be left unchanged.

Copilot uses AI. Check for mistakes.
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.

Add hard wrap limit option to console

2 participants