Skip to content

Add "Open Merge Editor for Current File" command to Git extension #251295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 12, 2025

Implements a new user-facing command in the Git extension that allows users to quickly open the merge editor for the currently active file when it contains merge conflicts.

Features

  • New Command: Git: Open Merge Editor for Current File available in the Command Palette
  • Smart Detection: Automatically detects merge conflicts by scanning for conflict markers (<<<<<<< and >>>>>>>)
  • User-Friendly: Shows informative messages when no active editor or conflicts are found
  • Contextual Availability: Only appears in Command Palette when a text editor is focused

Implementation Details

Command Behavior

  1. Checks if there's an active text editor
  2. Scans the current file for merge conflict markers using line-by-line parsing
  3. If conflicts are found, opens the existing merge editor for the file
  4. If no conflicts, shows message: "No merge conflicts found in the current file"
  5. If no active editor, shows message: "No active text editor found"

Technical Changes

  • CommandCenter.openMergeEditorForCurrentFile(): Main command implementation
  • CommandCenter.hasConflictMarkers(): Robust conflict detection helper method
  • package.json: Command contribution with editorTextFocus enablement condition
  • package.nls.json: Localized command title

Conflict Detection

The implementation uses a robust line-by-line scanner that:

  • Looks for lines starting with <<<<<<< (conflict start)
  • Tracks when conflict end markers >>>>>>> are found
  • Avoids false positives from conflict markers in comments or strings
  • Reuses existing merge editor functionality

Usage

  1. Open a file with merge conflicts
  2. Open Command Palette (Ctrl+Shift+P / Cmd+Shift+P)
  3. Search for "Open Merge Editor for Current File"
  4. The merge editor will open automatically if conflicts are detected

This enhancement improves the developer workflow by providing quick access to merge conflict resolution without needing to navigate through the SCM view or right-click menus.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • electronjs.org
    • Triggering command: node-gyp (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: joaomoreno <22350+joaomoreno@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Add 'Open Merge Editor for Current File' Command to Git Extension Add "Open Merge Editor for Current File" command to Git extension Jun 12, 2025
@Copilot Copilot AI requested a review from joaomoreno June 12, 2025 16:37
Copilot finished work on behalf of joaomoreno June 12, 2025 16:38
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

Error loading sessions

Retrying...

Successfully merging this pull request may close these issues.

2 participants