Trim console lines that are longer than limit#2466
Trim console lines that are longer than limit#2466trancexpress wants to merge 1 commit intoeclipse-platform:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR attempts to fix issue #2465, where the console character limit doesn't apply to lines that are longer than the limit. The issue occurs when a single line without newlines exceeds the console's high water mark - the existing trimming logic tries to trim to the start of the line (offset 0), resulting in no content being removed.
Changes:
- Modified the
trim()method inIOConsolePartitionerto handle the case where a single line exceeds the character limit
Comments suppressed due to low confidence (1)
debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java:1207
- This fix lacks test coverage for the specific issue it's attempting to address. The existing testTrim() method only tests trimming with multiple lines (each line is "0123456789\n"). There should be a test that reproduces the scenario from issue #2465: a single very long line (e.g., 100,000 characters without newlines) with the console limit set to a lower value (e.g., 80,000 characters), to verify that the console properly trims the content even when it's all on one line.
// deal with case of one long line
cutOffset = Math.max(cutOffset, truncateOffset);
cutOffset = document.getLineOffset(cutoffLine);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java:1206
- The comment "deal with case of one long line" is misleading. This logic applies to any line that is longer than the trim threshold, not just when there is only one line in the document. Consider updating the comment to clarify that this handles cases where individual lines exceed the buffer limit, for example: "trim within line if line is longer than buffer limit" or "ensure trimming happens even when line start would keep too much data".
// deal with case of one long line
debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java:1207
- The fix addresses a specific edge case (very long single lines exceeding the console limit), but there is no test coverage added for this scenario. Consider adding a test similar to testTrim() but with a single very long line (e.g., 100,000 characters without newlines) to verify that trimming works correctly when the high water mark is exceeded. This would prevent regression of the bug described in issue #2465.
// deal with case of one long line
cutOffset = Math.max(cutOffset, truncateOffset);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Test fails to look into: |
|
The fail in
(i.e. the output of the snippet above) While the test expects: The expectations are due to the code we need to change: If IMO the test expectations should be adjusted. @iloveeclipse WDYT? |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleTests.java:719
- Changing the expected offset to
1indicates trimming now leaves a leading newline (i.e., trims at an arbitrary offset instead of the start of a line). That seems like a regression from the original “trim to line start” behavior and doesn’t directly validate the long-line limit fix from #2465. Consider keeping the expectation at offset0for the normal multi-line case, and add a dedicated assertion/test scenario for a single line longer than the high-water mark (no newline) to ensure the buffer actually shrinks whentruncateToOffsetLineStartwould otherwise result incutOffset == 0.
c.getConsole().setWaterMarks(50, 100);
c.waitForScheduledJobs();
c.verifyContentByOffset("0123456789", 1);
assertTrue(c.getDocument().getNumberOfLines() < 15, "Document not trimmed.");
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes: #2465