fix: support keybinding invocation for git reveal commands#297211
Open
yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
Open
fix: support keybinding invocation for git reveal commands#297211yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
Conversation
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
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @lszomoruMatched files:
|
Contributor
Author
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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) andgit.revealInExplorersilently do nothing when invoked via a keybinding. This is because both commands expect aSourceControlResourceStateargument 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 atif (!resourceState) { return; }.Closes #260898
What is the new behavior?
When no
resourceStateargument is provided (keybinding invocation), both commands now fall back to:this.getSCMResource()— resolves the SCM resource for the active editor's documentwindow.activeTextEditor?.document.uri— uses the active editor's URI directlyThis matches the existing pattern used by
openFile(line 1259-1261) andignore(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
revealInExplorerandrevealFileInOSnow 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