Bug 552906 - Editor has no focus/cursor after tab switch
Summary: Editor has no focus/cursor after tab switch
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.14   Edit
Hardware: PC All
: P3 blocker (vote)
Target Milestone: 4.14 M3   Edit
Assignee: Andrey Loskutov CLA
QA Contact:
URL:
Whiteboard:
Keywords: regression, triaged
Depends on:
Blocks: 473941
  Show dependency tree
 
Reported: 2019-11-11 09:12 EST by Jonas Hungershausen CLA
Modified: 2019-11-23 14:59 EST (History)
4 users (show)

See Also:


Attachments
GIf showing the steps (1.13 MB, image/gif)
2019-11-11 10:01 EST, Jonas Hungershausen CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonas Hungershausen CLA 2019-11-11 09:12:29 EST
When switching editor tabs the editor is not automatically focused in the latest (yesterday evening) I build.

A related test is failing on Gerrit too (not on the nightly build though): https://ci.eclipse.org/platform/job/eclipse.platform.ui-Gerrit/20754/testReport/junit/org.eclipse.e4.ui.tests.workbench/PartOnTopManagerTest/test_PartOnTopPerspectiveSwitch/

Eclipse SDK
Version: 2019-12 (4.14)
Build id: I20191110-1800
OS: Linux, v.5.3.0-19-generic, x86_64 / gtk 3.24.12, WebKit 2.26.1
Java version: 1.8.0_222
Comment 1 Andrey Loskutov CLA 2019-11-11 09:14:56 EST
Works for me, RHEL 7.4, same SDK build.

Concrete steps to reproduce?
Comment 2 Lars Vogel CLA 2019-11-11 09:37:13 EST
Maybe related, we see the following test fail on Gerrit:

org.eclipse.e4.ui.tests.workbench.PartOnTopManagerTest.test_PlaceholderOnTopStackSwitch
Comment 3 Lars Vogel CLA 2019-11-11 09:37:31 EST
(In reply to Lars Vogel from comment #2)
> Maybe related, we see the following test fail on Gerrit:
> 
> org.eclipse.e4.ui.tests.workbench.PartOnTopManagerTest.
> test_PlaceholderOnTopStackSwitch

For example: https://git.eclipse.org/r/#/c/152414/
Comment 4 Jonas Hungershausen CLA 2019-11-11 09:41:23 EST
(In reply to Andrey Loskutov from comment #1)
> Works for me, RHEL 7.4, same SDK build.
> 
> Concrete steps to reproduce?

For me, I just opened a bunch of editors (Java for that matter) and then switched between them. Once I clicked on a tab and the respective editor opened I expect to be inside the editor and that I can type inside the editor which is not the case.

OS is Ubuntu 19.10
Comment 5 Andrey Loskutov CLA 2019-11-11 09:52:51 EST
(In reply to Jonas Hungershausen from comment #4)
> (In reply to Andrey Loskutov from comment #1)
> > Works for me, RHEL 7.4, same SDK build.
> > 
> > Concrete steps to reproduce?
> 
> For me, I just opened a bunch of editors (Java for that matter) and then
> switched between them. Once I clicked on a tab and the respective editor
> opened I expect to be inside the editor and that I can type inside the
> editor which is not the case.

So you are not inside the editor or you can't type? Could it be just painting issue - obviously, you *can* type via keyboard, but I guess you can't see changed text and/or editor tab is not getting dirty "*" sign?

*I* can type after switching editors by clicking on the editor tab or by using "next editor" shortcut. How do *you* switch editors? Any errors in the log?

If you can reproduce, please either provide a video or write down exact steps (opened editor via double click in packages view, etc).
Comment 6 Jonas Hungershausen CLA 2019-11-11 10:01:58 EST
Created attachment 280592 [details]
GIf showing the steps

So the problem doesn't occur when I directly switch between tabs (as I incorrectly described earlier—sorry!). It rather happens, when I switch from an editor to another part, then switch to a different editor tab and then back to the original one.

As you can see in the video, once I was back to the "FlutterLibChangeListener" at the end I couldn't type, which I don't think is intended.
Comment 7 Andrey Loskutov CLA 2019-11-11 10:14:56 EST
OK, now with a *different* set of files and my own steps I see the problem.

1) In Java perspective, close all editors
2) Double click on /org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java to open SWT.java. Note that the cursor is there, typing is possible.
3) Double click on /org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWTError.java to open SWTError.java. Note that the cursor is there, typing is possible.
4) Click once on the SWT.java editor tab to switch back to SWT.java. Note that the cursor is NOT there, typing does not have any visible effect. Only clicking with the mouse *inside* the editor text area allows you to change the text.

From the recent changes I could imagine bug 371545 is the cause, but I haven't verified that yet.

Eric, could you check?
Comment 8 Andrey Loskutov CLA 2019-11-11 10:40:18 EST
Interestingly, I can't reproduce this behavior in the debugger, it just works. Why that? Some SDK project in my workspace that prevents it to happen?
Comment 9 Eric Williams CLA 2019-11-11 10:44:39 EST
*sigh* it's always something.

I'll investigate.

Unrelated: I did not get emailed for this incoming bug report, even though I follow platform-swt-inbox and it's been working for years...
Comment 10 Eric Williams CLA 2019-11-11 11:46:06 EST
I can't reproduce the steps from comment 6 or comment 7. This is using a child Eclipse on SWT master, Fedora 31, GTK3.24.

Let me try a standalone build.
Comment 11 Andrey Loskutov CLA 2019-11-11 12:03:00 EST
(In reply to Eric Williams from comment #10)
> I can't reproduce the steps from comment 6 or comment 7. This is using a
> child Eclipse on SWT master, Fedora 31, GTK3.24.
> 
> Let me try a standalone build.

Yep, see comment 8.
Comment 12 Eric Williams CLA 2019-11-11 12:08:50 EST
Okay, was able to reproduce the issue in a child Eclipse using steps from comment 6. Oddly enough it only reproduces if you click in the Outline part after editing the first file. Clicking anywhere else doesn't reproduce it.

The issue reproduces with bug 371545 reverted, so I don't think it's that.
Comment 13 Andrey Loskutov CLA 2019-11-11 12:11:17 EST
I must confess that I haven't tried with Windows. May be it is not SWT, but platform UI?
Comment 14 Eric Williams CLA 2019-11-11 12:15:48 EST
(In reply to Andrey Loskutov from comment #13)
> I must confess that I haven't tried with Windows. May be it is not SWT, but
> platform UI?

Could be. My steps to reproduce:

1) Have two files open in the Java perspective.
2) Click the tab of the first file. Type some stuff, hit Ctrl+z so nothing is edited.
3) Click into the blank area of the "Outline" view.
4) Click the tab of the second file. Type some stuff, hit Ctrl+z so nothing is edited.
5) Click tab of first file. Notice that the cursor isn't painted and nothing will be typed if you press a bunch of keys.
Comment 15 Paul Pazderski CLA 2019-11-11 12:16:04 EST
(In reply to Andrey Loskutov from comment #7)
> OK, now with a *different* set of files and my own steps I see the problem.
> 
> 1) In Java perspective, close all editors
> 2) Double click on /org.eclipse.swt/Eclipse
> SWT/common/org/eclipse/swt/SWT.java to open SWT.java. Note that the cursor
> is there, typing is possible.
> 3) Double click on /org.eclipse.swt/Eclipse
> SWT/common/org/eclipse/swt/SWTError.java to open SWTError.java. Note that
> the cursor is there, typing is possible.
> 4) Click once on the SWT.java editor tab to switch back to SWT.java. Note
> that the cursor is NOT there, typing does not have any visible effect. Only
> clicking with the mouse *inside* the editor text area allows you to change
> the text.
> 
> From the recent changes I could imagine bug 371545 is the cause, but I
> haven't verified that yet.
> 
> Eric, could you check?

Could reproduce those steps on Windows 7. Same result.
Comment 16 Paul Pazderski CLA 2019-11-11 12:17:19 EST
Same for Eric's steps in comment 14.
Comment 17 Andrey Loskutov CLA 2019-11-11 12:19:50 EST
(In reply to Eric Williams from comment #12)
> The issue reproduces with bug 371545 reverted, so I don't think it's that.

Sorry Eric, was just a first guess.

(In reply to Paul Pazderski from comment #16)
> Same for Eric's steps in comment 14.

Thanks Paul. Had no time to test on Windows.
Comment 18 Paul Pazderski CLA 2019-11-11 13:12:14 EST
A more dense version of Eric's steps. The Ctrl+Z isn't necessary.

1. In an open editor, click on outline view (not necessary the empty part).
2. Select another editor.
3. Switch back to the first editor.

Now most typing seem to be lost but in fact it is entered in the previous editor. At the same time key commands like Ctrl+Z or Alt+Up are not sent to the previous editor but processed by the selected editor.
Comment 19 Andrey Loskutov CLA 2019-11-11 13:56:53 EST
Regression is in (I20190920-1800, I20190923-0615] range, I have no versions in between, but reverting commit aa8cc8120a501ef61938bd9f39c63ff26c71b1d6 fixes the problem in comment 18, so bug 473941 is it.

Can't reproduce my steps from comment 7 on Windows.

I will revert that change now.
Comment 20 Andrey Loskutov CLA 2019-11-11 14:01:06 EST
(In reply to Andrey Loskutov from comment #19)
> I will revert that change now.

https://git.eclipse.org/r/152448
Comment 21 Andrey Loskutov CLA 2019-11-12 03:18:11 EST
(In reply to Andrey Loskutov from comment #19)
> I will revert that change now.

Gerrit change https://git.eclipse.org/r/152448 was merged to [master].
Commit: http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=b00c85436f067e43337eedae4095db9e5fd407eb

Reverted commit is in build I20191111-1800, here I can't reproduce neither comment 7 nor comment 18 steps anymore (on Linux), so that was it, marking this bug as resolved. 

Thanks Jonas for catching this issue!