Skip to content

Add hard wrap limit option to console#2494

Open
trancexpress wants to merge 2 commits intoeclipse-platform:masterfrom
trancexpress:gh2479
Open

Add hard wrap limit option to console#2494
trancexpress wants to merge 2 commits 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

    51 files  ±  0      51 suites  ±0   35m 40s ⏱️ - 1m 26s
 4 819 tests +264   4 797 ✅ +268   22 💤 ±0  0 ❌  - 4 
12 405 runs  +144  12 249 ✅ +148  156 💤 ±0  0 ❌  - 4 

Results for commit c90a832. ± Comparison against base commit 9e8a07f.

♻️ This comment has been updated with latest results.

@trancexpress trancexpress force-pushed the gh2479 branch 4 times, most recently from 34508dc to 117fa34 Compare April 11, 2026 14:06
@trancexpress trancexpress marked this pull request as ready for review April 11, 2026 15:56
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 thread debug/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java Outdated
@trancexpress trancexpress force-pushed the gh2479 branch 2 times, most recently from b5b841b to 70b6a8a Compare April 11, 2026 19:45
@trancexpress
Copy link
Copy Markdown
Contributor Author

From my POV the remaining issue here is:

Applying the console buffer limit asynchronously is something that is likely not noticed. But the trim/wrap added here not applying is noticed immediately: starting Eclipse, launch a program, expected wrap/trim is not seen.

Considering that the new preference applies to the input stream itself, not to the document in the console, maybe we should read the preference in org.eclipse.ui.internal.console.IOConsolePartitioner and not set it from org.eclipse.debug.internal.ui.views.console.ProcessConsole.init() (which is called in parallel). But then why set any of the preferences in ProcessConsole.init().

So same as before, no idea what to do about this.

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
@iloveeclipse
Copy link
Copy Markdown
Member

Just rebased.

@iloveeclipse
Copy link
Copy Markdown
Member

Just smoke tested it, from user perspective, it does what it is supposed to do, however new preferences in the UI could use better wording:
image

To better explain the difference and the "duality" of new "limit" & "wrap" options, I would provide radio boxes, and also would pu everything in a group:

image

I will push this one change now as extra commit & continue with review of the rest later.

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

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


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

Comment on lines +827 to +831
if (lineModifier != null) {
List<PendingPartition> modified = new ArrayList<>(pendingCopy.size());
for (PendingPartition partition : pendingCopy) {
CharSequence t = lineModifier.modify(partition.text);
PendingPartition m = new PendingPartition(partition.stream, t);
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

lineModifier.modify(...) is applied to the entire drained queue before the high-water-mark logic potentially drops the leading PendingPartitions. If output is dropped, the modifier's state (e.g., current line length) will have already advanced based on text that will never reach the document, which can cause incorrect wrap/truncate results for the remaining partitions (e.g., inserting a wrap immediately at the start of the kept text). Consider trimming pendingCopy first, and if any partitions are dropped call lineModifier.reset() and then apply modify(...) only to the kept partitions (or otherwise recompute state based on what will actually be appended).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Probably we can apply the limit first, then the new code...

Comment on lines +1553 to +1560
private void setLineModifier() {
if (document != null && lineLengthLimit > 0) {
String[] lineDelimiters = document.getLegalLineDelimiters();
lineModifier = lineLimitWrap ? new ConsoleOutputLineWrap(lineLengthLimit, lineDelimiters)
: new ConsoleOutputLineTruncate(lineLengthLimit, lineDelimiters);
} else {
lineModifier = null;
}
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

IConsoleOutputModifier is stateful (tracks current line length across chunks), but the modifier is never reset when the console content is cleared (document length becomes 0 / clearBuffer()), meaning the next output after a clear can be wrapped/truncated as if it continued the previous line. Consider resetting modifier state when the document is cleared (e.g., in the documentChanged2 branch for document.getLength() == 0 and/or in clearBuffer()), and also when replacing the modifier instance in this method.

Copilot uses AI. Check for mistakes.
Comment on lines +520 to +522
Button button = new Button(parent, SWT.RADIO | SWT.LEFT);
button.setText(label);
return button;
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

This page introduces a local createRadioButton(...) helper that duplicates SWTFactory.createRadioButton(...) but omits standard setup (font, GridData, and setButtonDimensionHint). This can lead to inconsistent sizing/alignment compared to other radio buttons in the Debug UI. Prefer reusing SWTFactory.createRadioButton(...) (or at least mirror its initialization) and remove the duplicate helper if possible.

Suggested change
Button button = new Button(parent, SWT.RADIO | SWT.LEFT);
button.setText(label);
return button;
return SWTFactory.createRadioButton(parent, label);

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

3 participants