Bug 412881 - caret disappears when renaming class
Summary: caret disappears when renaming class
Status: RESOLVED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.3   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2013-07-12 14:47 EDT by Rafael Chaves CLA
Modified: 2021-09-22 07:21 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Chaves CLA 2013-07-12 14:47:57 EDT
Steps:
1) Open a Java class in the Java editor
2) Select the class name in the source, trigger the class rename refactor (Alt-shift-R)
3) Give it a new name
4) Once the refactor completes, the cursor is gone. Everything else still works (line highlighting as well)

Switching the focus to another view/editor (or OS window) and back brings it back.
Comment 1 Noopur Gupta CLA 2013-07-15 02:37:48 EDT
Cannot reproduce this with Eclipse 4.3 (Kepler).
Please provide an example with some additional info that could help to reproduce the issue.
Comment 2 Rafael Chaves CLA 2013-07-15 02:40:47 EDT
Did you try it on Linux? What additional information do you need?
Comment 3 Noopur Gupta CLA 2013-07-15 02:48:35 EDT
(In reply to comment #2)
> Did you try it on Linux? What additional information do you need?

I was trying on Windows 7.
Reopening as I am able to reproduce it on Linux.
Comment 4 Dani Megert CLA 2013-07-15 07:15:52 EDT
- Is the caret or the mouse cursor lost (not the same thing ;-)?
- Does it work in 3.8?
Comment 5 Noopur Gupta CLA 2013-07-15 07:28:16 EDT
(In reply to comment #4)
> - Is the caret or the mouse cursor lost (not the same thing ;-)?
The caret is lost. Mouse cursor can still be used to perform selection and other actions.
> - Does it work in 3.8?
Checked in 3.8.1 on Linux, it used to work there.
Comment 6 Dani Megert CLA 2013-07-15 07:41:26 EDT
(In reply to comment #5)
> (In reply to comment #4)
> > - Is the caret or the mouse cursor lost (not the same thing ;-)?
> The caret is lost. Mouse cursor can still be used to perform selection and
> other actions.
> > - Does it work in 3.8?
> Checked in 3.8.1 on Linux, it used to work there.

OK. Please also check 4.2.1, to see whether it's a general regression or a 4.x specific problem.
Comment 7 Dani Megert CLA 2013-07-15 07:42:48 EDT
I can also reproduce it on our Linux machine with 4.3, but only when I rename the type where it is declared, i.e. if I rename a reference, then it's OK.
Comment 8 Noopur Gupta CLA 2013-07-15 08:14:08 EDT
(In reply to comment #6)
> OK. Please also check 4.2.1, to see whether it's a general regression or a
> 4.x specific problem.
It works properly in 4.2.1 also.
Comment 9 Dani Megert CLA 2013-07-15 10:28:21 EDT
Also works fine on Mac OS X.

Markus and I looked at it: The problem only happens when using a custom caret, which we do by default. For unknown reasons, the workbench shell does not have any focus control when we set the custom caret on StyledText during the rename, but at the end of the rename, the focus is on StyledText. However, the caret is not drawn. We tried to produce a snippet based on that information, but had no luck.
Comment 10 Rafael Chaves CLA 2013-07-15 11:32:55 EDT
(In reply to comment #7)
> I can also reproduce it on our Linux machine with 4.3, but only when I
> rename the type where it is declared, i.e. if I rename a reference, then
> it's OK.

I was suspecting the issue had to do with the editor having to be updated to work on a different file name. I looked into recreating it using the text editor but there is no way to rename a file from within that editor - doing the rename from the navigator or package explorer is not the same, as toggling between views avoids the bug.
Comment 11 Markus Keller CLA 2013-07-15 16:19:30 EDT
Some background on what happens in the Rename in Editor implementation in RenameLinkedMode#doRename(boolean):

- we take a screenshot and place it on top of the StyledText (hack that was necessary because there's no way to stop StyledText from redrawing when the underlying document is modified)

- we perform the refactoring using the workbench window as runnable context
  - this temporarily disables most widgets in the workbench, except for the Stop button in the progress trim item (but there were bugs around that in 4.3, see bug 409423 and other bugs mentioned there)

- during the refactoring, the .java file gets renamed, and a lot happens in the editor to show the new input (renamed file)

- the WorkbenchWindow#run(..) method restores widget enablement and calls forceFocus() on the editor's StyledText (which is still the same instance as when the refactoring was started)

- in the end, we dispose the Label with the screenshot, which
Comment 12 Eric Williams CLA 2018-05-14 16:01:39 EDT
I cannot reproduce this issue on GTK3.22, 4.8 M7, and Fedora 28.