Skip to content

fix: support keybinding invocation for git reveal commands#297211

Open
yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
yogeshwaran-c:fix/git-reveal-keybinding-support
Open

fix: support keybinding invocation for git reveal commands#297211
yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
yogeshwaran-c:fix/git-reveal-keybinding-support

Conversation

@yogeshwaran-c
Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

The git.revealFileInOS.* commands (Open Containing Folder / Reveal in Finder / Reveal in File Explorer) and git.revealInExplorer silently do nothing when invoked via a keybinding. This is because both commands expect a SourceControlResourceState argument that is only provided when invoked from a context menu. When invoked via a keybinding, no argument is passed, so the function hits the early return at if (!resourceState) { return; }.

Closes #260898

What is the new behavior?

When no resourceState argument is provided (keybinding invocation), both commands now fall back to:

  1. this.getSCMResource() — resolves the SCM resource for the active editor's document
  2. window.activeTextEditor?.document.uri — uses the active editor's URI directly

This matches the existing pattern used by openFile (line 1259-1261) and ignore (line 4411-4412) commands in the same file, which already handle keybinding invocation gracefully.

Additional context

The fix is minimal and follows established conventions in the codebase. Both revealInExplorer and revealFileInOS now work identically whether invoked from a context menu or a keybinding.

Before: Keybinding for "Git: Open Containing Folder" does nothing
After: Keybinding reveals the active file's containing folder in the OS file manager

When git.revealInExplorer and git.revealFileInOS are invoked via a
keybinding rather than a context menu, no resourceState argument is
passed. Previously both commands returned early in this case, making
keybindings silently do nothing.

Add a fallback to getSCMResource() and the active text editor URI,
matching the existing pattern used by openFile and ignore commands.

Closes microsoft#260898
@vs-code-engineering
Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@lszomoru

Matched files:

  • extensions/git/src/commands.ts

@yogeshwaran-c
Copy link
Copy Markdown
Contributor Author

@yogeshwaran-c please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@yogeshwaran-c please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

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.

Keybinding for Git: Open Containing Folder doesn't work

3 participants