Skip to content

Reuse compare editor when opening the same changed file multiple times #47

@Philipp0205

Description

@Philipp0205

Summary

When opening a changed file multiple times from the changed files view, a new compare editor tab is created each time instead of reusing the existing editor. This clutters the editor area with duplicate tabs for the same file.

Current Behavior

  1. Open a pull request in the plugin
  2. Navigate to the changed files view
  3. Double-click or open a changed file → compare editor opens
  4. Double-click the same file again → a second compare editor tab opens for the same file
  5. Repeat → multiple duplicate tabs accumulate

Expected Behavior

When opening a changed file that already has an open compare editor:

  • The existing editor should be brought to focus/front
  • No new tab should be created
  • The user should see the already-open editor instance

This matches the standard Eclipse editor behavior for regular file editors.

Motivation

  • Reduces tab clutter: Users don't accumulate duplicate tabs during PR review
  • Improves navigation: Users can quickly return to files they've already opened
  • Consistency: Aligns with Eclipse IDE conventions where files reuse their editors
  • Better UX: Reduces cognitive load and manual tab management

Acceptance Criteria

  • Opening an already-open changed file brings the existing compare editor to front
  • No duplicate compare editor tabs are created for the same file
  • Behavior works consistently from the changed files view
  • If the file content has changed (e.g., new commits), the editor updates accordingly

Technical Considerations

  • Check if a compare editor is already open for the file path before creating a new one
  • Use Eclipse's IWorkbenchPage.findEditor() or similar API to locate existing editors
  • May need to store editor input metadata to match against opened files
  • Consider how this interacts with different compare editor types (inline vs. side-by-side)

Additional Context

This enhancement improves the user experience during pull request reviews where developers frequently revisit the same files while reviewing comments or making comparisons.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions