eclipse.platform.ui icon indicating copy to clipboard operation
eclipse.platform.ui copied to clipboard

Draw completion proposals always as focused

Open Christopher-Hermann opened this issue 10 months ago • 14 comments

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: image

With the fix, the proposal is colored in the focus color: image

How to retest

  1. Open a text editor and run the code completion (ctrl+space)
  2. Check that the selected completion proposal is colored in the focused color

Fixes #1688

Christopher-Hermann avatar Feb 12 '25 09:02 Christopher-Hermann

@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.

Christopher-Hermann avatar Feb 12 '25 09:02 Christopher-Hermann

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.

github-actions[bot] avatar Feb 12 '25 09:02 github-actions[bot]

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.

iloveeclipse avatar Feb 12 '25 10:02 iloveeclipse

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)

iloveeclipse avatar Feb 12 '25 15:02 iloveeclipse

I see errors on every popup close:

Yes I need to check this, there are also some "SWT Resource was not properly disposed" errors

Christopher-Hermann avatar Feb 13 '25 07:02 Christopher-Hermann

there are also some "SWT Resource was not properly disposed" errors

These are most likely follow ups of original error

iloveeclipse avatar Feb 13 '25 07:02 iloveeclipse

I see errors on every popup close:

Should be fixed.

Is the coloring working on Linux?

Christopher-Hermann avatar Feb 13 '25 18:02 Christopher-Hermann

@iloveeclipse can you confirm that the coloring is working on linux like expected?

MacOS and Windows is working. Then I would merge this change.

Christopher-Hermann avatar Feb 24 '25 13:02 Christopher-Hermann

Then I would merge this change.

You can't merge the change, we are in the RC phase.

iloveeclipse avatar Feb 24 '25 13:02 iloveeclipse

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).

image

iloveeclipse avatar Feb 24 '25 14:02 iloveeclipse

If there are no objections I would merge the PR

Christopher-Hermann avatar Mar 19 '25 07:03 Christopher-Hermann

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.

szarnekow avatar Mar 19 '25 21:03 szarnekow

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.

Christopher-Hermann avatar Mar 20 '25 13:03 Christopher-Hermann

I tried using SWT.COLOR_TITLE_INACTIVE_BACKGROUND if the control is not focused, but this is even more worse (at least on MacOS).

image

So I see two ways to solve the issue:

  1. Go with the approach as it is suggested in this PR: Just show the code completion as focus in any case
  2. 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.

Christopher-Hermann avatar Mar 21 '25 12:03 Christopher-Hermann