Skip to content

Fix: Outline view clicks ignored in Compare editor#313

Draft
Copilot wants to merge 6 commits intomasterfrom
copilot/fix-outline-view-click-behavior
Draft

Fix: Outline view clicks ignored in Compare editor#313
Copilot wants to merge 6 commits intomasterfrom
copilot/fix-outline-view-click-behavior

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 5, 2026

  • Investigated root cause of test failures: ScenarioPart extends DocumentRangeNode causes TextMergeViewer.ContributorInfo.setDocument() to take the IDocumentRange path, showing a 1-character raw-file slice instead of the extracted field content — breaking all structure-pane compare tests
  • Reverted ScenarioPart to original design (extends ScenarioResource, NOT DocumentRangeNode) — restores structure-pane compare behavior
  • Added fRawOffset / getRawOffset() / setRawOffset() to ScenarioPart, populated during getStructure() with the character offset of each section in the raw scenario file
  • Added ScenarioMergeViewerCreator / ScenarioMergeViewer extends TextMergeViewer for .test/.scenario files:
    • Overrides createSourceViewer() to capture left/right SourceViewer references (protected API, no reflection)
    • Overrides getAdapter(OutlineViewerCreator.class) to return ScenarioOutlineViewerCreator
    • ScenarioOutlineViewerCreator on Outline-view selection of a ScenarioPart calls revealOffset(rawOffset)ITextViewer.revealRange() (public API)
  • Registered ScenarioMergeViewerCreator for .test/.scenario in plugin.xml

Copilot AI and others added 3 commits May 5, 2026 14:21
…w navigation

The Compare editor was ignoring clicks in the Outline view when
'Show structure compare in Outline view when possible' was enabled.

Root cause: TextMergeViewer.InternalOutlineViewerCreator.selectionChanged()
calls findDiff() which checks if the selected element's left/right nodes are
DocumentRangeNode instances to get their document position. Since ScenarioPart
only implemented IStructureComparator/ITypedElement (not DocumentRangeNode),
getPosition() returned null and no navigation occurred.

Fix: Make ScenarioPart and ScenarioRoot extend DocumentRangeNode with
character offsets pointing to each section's location in the raw scenario file
text. This is analogous to how JDT's JavaNode extends DocumentRangeNode to
enable the same navigation in the Java compare editor.

When the user clicks a node in the Outline view (e.g. 'Script'), the text
viewer now scrolls to the first text diff at or after the script section's
position in the file, which is the expected behavior consistent with JDT.

Agent-Logs-Url: https://github.com/eclipse-rcptt/org.eclipse.rcptt/sessions/d4e9e421-f8a0-4efe-9eb7-bb341bc6657d

Co-authored-by: basilevs <650857+basilevs@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Compare editor ignoring double-clicks in Outline view Fix: Outline view clicks ignored in Compare editor May 5, 2026
Copilot AI requested a review from basilevs May 5, 2026 14:32
…or Outline view nav

The previous approach of extending DocumentRangeNode broke 5 existing compare
tests because TextMergeViewer.ContributorInfo.setDocument() takes the
IDocumentRange path when the element is a DocumentRangeNode, and then uses a
1-character raw-file slice instead of the extracted field content.

This commit:
1. Reverts ScenarioPart to the original design (extends ScenarioResource, not
   DocumentRangeNode) – this restores the structure-pane compare behavior that
   the existing tests validate.
2. Adds int fRawOffset / getRawOffset() / setRawOffset() to ScenarioPart,
   populated during getStructure() with the character offset of each section in
   the raw scenario file (same MIME-boundary search logic as before).
3. Adds ScenarioMergeViewerCreator / ScenarioMergeViewer extends TextMergeViewer
   for .test/.scenario files. ScenarioMergeViewer:
   - Overrides createSourceViewer() to capture the left and right SourceViewer
     references (no reflection needed – createSourceViewer() is protected API).
   - Overrides getAdapter(OutlineViewerCreator.class) to return a custom
     ScenarioOutlineViewerCreator that, on Outline-view selection of a
     ScenarioPart, calls revealOffset(rawOffset) which scrolls both captured
     source viewers to the section via ITextViewer.revealRange() (public API).
4. Registers ScenarioMergeViewerCreator for .test/.scenario in plugin.xml.

Agent-Logs-Url: https://github.com/eclipse-rcptt/org.eclipse.rcptt/sessions/713d3095-235f-4429-85a7-ce15a379f95d

Co-authored-by: basilevs <650857+basilevs@users.noreply.github.com>
return part;
}
}
public static final String STRUCTURE_COMPARE_TITLE = "Test Case Structure Compare"; //$NON-NLS-1$
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting is broken, no indent. Revert?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2378b5b — the class body was written without indentation due to a heredoc issue. Restored proper tab indentation throughout ScenarioStructureCreator.java.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compare editor ignores double-clicks in Outline view

2 participants