Skip to content

Fix console input cursor not repositioning after output - #2849

Merged
iloveeclipse merged 1 commit into
eclipse-platform:masterfrom
SougandhS:ConsoleCursorFix
Aug 4, 2026
Merged

Fix console input cursor not repositioning after output#2849
iloveeclipse merged 1 commit into
eclipse-platform:masterfrom
SougandhS:ConsoleCursorFix

Conversation

@SougandhS

@SougandhS SougandhS commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Added repositionCaretAfterOutput() to IOConsoleViewer to move the caret to the next writable input partition whenever output is written.
Before :
bfr

After :
dff

Fixes : #2127

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Test Results

    54 files  ±0      54 suites  ±0   59m 35s ⏱️ + 1m 21s
 4 705 tests +2   4 683 ✅ +3   22 💤 ±0  0 ❌  - 1 
12 006 runs  +3  11 853 ✅ +4  153 💤 ±0  0 ❌  - 1 

Results for commit 90552f6. ± Comparison against base commit 7beef1c.

♻️ This comment has been updated with latest results.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses Eclipse console usability by ensuring the input caret is repositioned to the next writable input partition after program output is written, aligning behavior with expectations described in issue #2127.

Changes:

  • Added repositionCaretAfterOutput() to IOConsoleViewer to move the caret to the next writable input partition.
  • Invoked caret repositioning after auto-scroll reveals the end of the document on document change events.

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

@SougandhS
SougandhS force-pushed the ConsoleCursorFix branch 2 times, most recently from 8d4fd59 to 576aed1 Compare August 4, 2026 01:13
@iloveeclipse

Copy link
Copy Markdown
Member

OK, looks good from the code point of view, tested with this snippet:

public class PrintAndRead {
    public static void main(String[] args) {
    	java.util.Scanner scanner = new java.util.Scanner(System.in);
        while (true) {
            System.out.print("Please type something: ");
            String input = scanner.nextLine();
            System.out.println("You typed: " + input);
        }
    }
}

Could you please add a test for this fix?

@SougandhS
SougandhS force-pushed the ConsoleCursorFix branch 2 times, most recently from 011f8b6 to 0593ec6 Compare August 4, 2026 10:27
@SougandhS

SougandhS commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Could you please add a test for this fix?

Added,
The failures looks unrelated - Passing on local

@iloveeclipse

Copy link
Copy Markdown
Member

Hmm. The failing tests are all about "not yet closed/disposed" consoles, interestingly they are all different and failing in different OS. The common thing is that some console is still "alive" and not closed.

the zoom font must be disposed once its console is removed ==> expected: <true> but was: <false>
org.opentest4j.AssertionFailedError: the zoom font must be disposed once its console is removed ==> expected: <true> but was: <false>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
	at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:214)
	at org.eclipse.debug.tests.console.ConsoleTests.testRemovingConsoleDisposesZoomFont(ConsoleTests.java:472)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Console close was not signaled. ==> expected: <true> but was: <false>
org.opentest4j.AssertionFailedError: Console close was not signaled. ==> expected: <true> but was: <false>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
	at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:214)
	at org.eclipse.debug.tests.console.IOConsoleTests.closeConsole(IOConsoleTests.java:211)
	at org.eclipse.debug.tests.console.IOConsoleTests.testConsoleClear(IOConsoleTests.java:258)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
[console has been added] 
Expected size: 1 but was: 2 in:
[Console [Test clear], Console [MockProcess]]
java.lang.AssertionError: 
[console has been added] 
Expected size: 1 but was: 2 in:
[Console [Test clear], Console [MockProcess]]
	at org.eclipse.debug.tests.console.ProcessConsoleManagerTests.testProcessConsoleLifecycle(ProcessConsoleManagerTests.java:88)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)

Added repositionCaretAfterOutput() to IOConsoleViewer to move the caret
to the next writable input partition whenever output is written.

Fixes : eclipse-platform#2127
@SougandhS

Copy link
Copy Markdown
Contributor Author

Build looks good now 👍

@iloveeclipse

Copy link
Copy Markdown
Member

Hmm. The failing tests are all about "not yet closed/disposed" consoles, interestingly they are all different and failing in different OS. The common thing is that some console is still "alive" and not closed.

I've created #2852.

@iloveeclipse
iloveeclipse merged commit fd48b43 into eclipse-platform:master Aug 4, 2026
18 checks passed
@iloveeclipse

Copy link
Copy Markdown
Member

Thanks!

iloveeclipse added a commit to iloveeclipse/eclipse.platform that referenced this pull request Aug 4, 2026
It seems that we either have race condition in ConsoleManager & related
code, or that some tests "leak" created Console instances and they are
popping around at unexpected times in other tests.

Let forcibly remove all Consoles in all tests related to ConsoleManager
and let assume before the test there are no Console instances flying
around.

See eclipse-platform#2849 (comment)
iloveeclipse added a commit that referenced this pull request Aug 4, 2026
It seems that we either have race condition in ConsoleManager & related
code, or that some tests "leak" created Console instances and they are
popping around at unexpected times in other tests.

Let forcibly remove all Consoles in all tests related to ConsoleManager
and let assume before the test there are no Console instances flying
around.

See #2849 (comment)
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.

Console input cursor does not reposition correctly after invalid input in Java program

3 participants