Bug 574710 - [merge tool] "Link with selection" doesn't always work
Summary: [merge tool] "Link with selection" doesn't always work
Status: RESOLVED FIXED
Alias: None
Product: EGit
Classification: Technology
Component: UI (show other bugs)
Version: 5.12   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 5.13   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-07 08:02 EDT by Thomas Wolf CLA
Modified: 2021-08-28 15:47 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wolf CLA 2021-07-07 08:02:36 EDT
Commit https://git.eclipse.org/r/c/egit/egit/+/32633 added code to GitMergeEditorInput to support linking with the package/project explorer when "Link with Editor" is switched on.

This works reasonably well if the merge editor shows a single file (and the left side adapts to IFile). Whenever the editor is activated, the package explorer shows the corresponding resource.

(The feature was requested in bug 399598, which is not referenced in the Gerrit change.)

However, this has side-effects and doesn't always work.

Side-effect: the history view, if set to follow the selection, also updates.
Wanted or not? If the comparison includes files not in the Eclipse workspace, the Git history will be replaced by the "Local history", which won't find any local file revisions. Doesn't seem to be very useful.

Open a merge editor on several conflicting files. Now following the selection doesn't work always. The CompareEditor's SelectionProvider tracks only the compare viewer (lower pane), not the DiffViewer showing the folder structure top left. But the EGit CompareEditorInput adapts to the selected file in that DiffViewer.

These selection changes are picked up reliably only when the CompareEditor is activated. Sometimes they are picked up when a folder is selected, but then the file being shown is the one that was selected before. Just selecting another file in the DiffViewer does not make the package explorer follow (but it will if one activates another view, then the compare editor again).

It's also possible to have situations where the CompareEditor shows a comparison of one file, but another file is selected in the DiffViewer (but not shown in the lower pane yet). In this case the package explorer and the history view will show the file selected in the DiffViewer, while the CompareEditor still shows a different comparison.

This is all very much inconsistent. I even managed to end up in a state where the commit editor showed a comparison on one file, the package explorer had another file selected, and the history view showed the history of yet another (previously selected in the commit editor) file.

Perhaps the adaptation should be changed to not adapt to the file selected in the DiffViewer but to the file actually shown in the lower pane, if any, and
use the DiffViewer selection only as a fallback (or not at all).
Comment 1 Thomas Wolf CLA 2021-07-07 13:10:00 EDT
PackageExplorer react on part activations and on EditorInputChanged events from the active part.

A CompareEditor's input is the whole CompareEditorInput. It doesn't change when selections in the DiffTreeViewer change, and it doesn't change when a new file comparison is shown in the lower pane.

That explains why the behavior is so erratic with a multi-file comparison.

A work-around hack might be to emit fake "input changed" events. But that needs reflection to get at WorkbenchPart.firePropertyChange to be able to call firePropertyChange(IEditorPart.PROP_INPUT).

I'd rather drop this whole linking feature for CompareEditors with multiple files.

Instead: a CompareEditor can act as an IShowInSource (even though by default the "Show In" menu is not shown anywhere). I think we can actually make this menu appear in the context menu of the DiffTreeViewer, and then the user can control which file he wants to see where and when.
Comment 2 Thomas Wolf CLA 2021-07-07 14:34:53 EDT
(In reply to Thomas Wolf from comment #1)
> Instead: a CompareEditor can act as an IShowInSource (even though by default
> the "Show In" menu is not shown anywhere).

Minor correction: it is available in the global "Navigate" menu.
Comment 3 Eclipse Genie CLA 2021-07-18 11:52:27 EDT
New Gerrit change created: https://git.eclipse.org/r/c/egit/egit/+/183148
Comment 4 Eclipse Genie CLA 2021-07-18 11:52:31 EDT
New Gerrit change created: https://git.eclipse.org/r/c/egit/egit/+/183150