Draw completion proposals always as focused
Problem description
When opening the completion proposals via the keyboard, the focus will stay in the editor to be able to accept further user input. This is causing the completion proposal to be drawn in non focus colors. This colors can lead to UX problems, especially in dark theme. With this fix, the completion proposals are always drawn in focused colors.
Before the fix in dark theme, it was hard to sport the selected proposal:
With the fix, the proposal is colored in the focus color:
How to retest
- Open a text editor and run the code completion (ctrl+space)
- Check that the selected completion proposal is colored in the focused color
Fixes #1688
@iloveeclipse I had fixed this issue in the past, but we had to revert the changes since you found some issues on Linux: https://github.com/eclipse-platform/eclipse.platform.ui/pull/1690 Could you please check if this more local fix is working on Linux?
On Mac and Windows it looks good.
Test Results
1 824 files ±0 1 824 suites ±0 1h 33m 17s ⏱️ +8s 7 918 tests ±0 7 690 ✅ ±0 228 💤 ±0 0 ❌ ±0 23 841 runs ±0 23 093 ✅ ±0 748 💤 ±0 0 ❌ ±0
Results for commit 8bb592a9. ± Comparison against base commit 1e6e9a98.
:recycle: This comment has been updated with latest results.
I will test later, but in general I would assume this is not for this release, M3 is planned for tomorrow and the change affects everyone using content assist.
Could you please check if this more local fix is working on Linux?
On Mac and Windows it looks good.
I see errors on every popup close:
!ENTRY org.eclipse.ui 4 0 2025-02-12 16:51:52.599
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NullPointerException: Cannot invoke "org.eclipse.swt.widgets.Widget.getDisplay()" because "event.item" is null
at org.eclipse.jface.contentassist.CompletionProposalDrawSupport.handleEvent(CompletionProposalDrawSupport.java:54)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:91)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5862)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1652)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1678)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1657)
at org.eclipse.swt.widgets.Widget.release(Widget.java:1396)
at org.eclipse.swt.widgets.Control.release(Control.java:4753)
at org.eclipse.swt.widgets.Composite.releaseChildren(Composite.java:1576)
at org.eclipse.swt.widgets.Canvas.releaseChildren(Canvas.java:279)
at org.eclipse.swt.widgets.Decorations.releaseChildren(Decorations.java:503)
at org.eclipse.swt.widgets.Shell.releaseChildren(Shell.java:3437)
at org.eclipse.swt.widgets.Widget.release(Widget.java:1403)
at org.eclipse.swt.widgets.Control.release(Control.java:4753)
at org.eclipse.swt.widgets.Widget.dispose(Widget.java:576)
at org.eclipse.swt.widgets.Shell.dispose(Shell.java:3354)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.hide(CompletionProposalPopup.java:1094)
at org.eclipse.jface.text.contentassist.AsyncCompletionProposalPopup.hide(AsyncCompletionProposalPopup.java:359)
at org.eclipse.jface.text.contentassist.ContentAssistant.hide(ContentAssistant.java:2268)
at org.eclipse.jface.text.contentassist.ContentAssistant$Closer.mouseDown(ContentAssistant.java:221)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:230)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:91)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5862)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1652)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:5072)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4524)
I see errors on every popup close:
Yes I need to check this, there are also some "SWT Resource was not properly disposed" errors
there are also some "SWT Resource was not properly disposed" errors
These are most likely follow ups of original error
I see errors on every popup close:
Should be fixed.
Is the coloring working on Linux?
@iloveeclipse can you confirm that the coloring is working on linux like expected?
MacOS and Windows is working. Then I would merge this change.
Then I would merge this change.
You can't merge the change, we are in the RC phase.
can you confirm that the coloring is working on linux like expected?
I can't observe the original problem on Linux. The proposal table without this change looks exactly as with the change (blue selection on dark background).
If there are no objections I would merge the PR
If there are no objections I would merge the PR
Personally I find the focus color to distracting - it grabs too much of my attention while typing.
Personally I find the focus color to distracting - it grabs too much of my attention while typing.
Yes, good point. I will check if we can just change the non focus color to something more visible. The problem is, as far as I understood, that on Linux the code completion is always rendered with focus back ground color. So when changing the color, it will most probably change the behavior on Linux.
I tried using SWT.COLOR_TITLE_INACTIVE_BACKGROUND if the control is not focused, but this is even more worse (at least on MacOS).
So I see two ways to solve the issue:
- Go with the approach as it is suggested in this PR: Just show the code completion as focus in any case
- Introduce color definitions for table selections, as it was done in #1690. Later on, when work on #1690 is continued, we can reuse the already existing color definitions.