Add "Open Containing Folder" etc to file context menu in Git SCM view (#149150)

* Add "Open Containing Folder" etc to file context menu in Git SCM view

Caption is "Reveal in Finder" on macOS and "Reveal in File Explorer" on Windows.
This resolves #137828

* Use multiple decorators on a method to simplify code
This commit is contained in:
John Murray 2022-05-13 08:48:36 +01:00 committed by GitHub
parent 81e412cf52
commit 479abbf95e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 93 additions and 3 deletions

View file

@ -459,6 +459,21 @@
"title": "%command.revealInExplorer%",
"category": "Git"
},
{
"command": "git.revealFileInOS.linux",
"title": "%command.revealFileInOS.linux%",
"category": "Git"
},
{
"command": "git.revealFileInOS.mac",
"title": "%command.revealFileInOS.mac%",
"category": "Git"
},
{
"command": "git.revealFileInOS.windows",
"title": "%command.revealFileInOS.windows%",
"category": "Git"
},
{
"command": "git.stashIncludeUntracked",
"title": "%command.stashIncludeUntracked%",
@ -761,6 +776,18 @@
"command": "git.revealInExplorer",
"when": "false"
},
{
"command": "git.revealFileInOS.linux",
"when": "false"
},
{
"command": "git.revealFileInOS.mac",
"when": "false"
},
{
"command": "git.revealFileInOS.windows",
"when": "false"
},
{
"command": "git.undoCommit",
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0"
@ -1211,7 +1238,22 @@
{
"command": "git.revealInExplorer",
"when": "scmProvider == git && scmResourceGroup == merge",
"group": "2_view"
"group": "2_view@1"
},
{
"command": "git.revealFileInOS.linux",
"when": "scmProvider == git && scmResourceGroup == merge && isLinux",
"group": "2_view@2"
},
{
"command": "git.revealFileInOS.mac",
"when": "scmProvider == git && scmResourceGroup == merge && isMac",
"group": "2_view@2"
},
{
"command": "git.revealFileInOS.windows",
"when": "scmProvider == git && scmResourceGroup == merge && isWindows",
"group": "2_view@2"
},
{
"command": "git.openFile2",
@ -1251,7 +1293,22 @@
{
"command": "git.revealInExplorer",
"when": "scmProvider == git && scmResourceGroup == index",
"group": "2_view"
"group": "2_view@1"
},
{
"command": "git.revealFileInOS.linux",
"when": "scmProvider == git && scmResourceGroup == index && isLinux",
"group": "2_view@2"
},
{
"command": "git.revealFileInOS.mac",
"when": "scmProvider == git && scmResourceGroup == index && isMac",
"group": "2_view@2"
},
{
"command": "git.revealFileInOS.windows",
"when": "scmProvider == git && scmResourceGroup == index && isWindows",
"group": "2_view@2"
},
{
"command": "git.openFile2",
@ -1316,7 +1373,22 @@
{
"command": "git.revealInExplorer",
"when": "scmProvider == git && scmResourceGroup == workingTree",
"group": "2_view"
"group": "2_view@1"
},
{
"command": "git.revealFileInOS.linux",
"when": "scmProvider == git && scmResourceGroup == workingTree && isLinux",
"group": "2_view@2"
},
{
"command": "git.revealFileInOS.mac",
"when": "scmProvider == git && scmResourceGroup == workingTree && isMac",
"group": "2_view@2"
},
{
"command": "git.revealFileInOS.windows",
"when": "scmProvider == git && scmResourceGroup == workingTree && isWindows",
"group": "2_view@2"
},
{
"command": "git.openChange",

View file

@ -80,6 +80,9 @@
"command.showOutput": "Show Git Output",
"command.ignore": "Add to .gitignore",
"command.revealInExplorer": "Reveal in Explorer View",
"command.revealFileInOS.linux": "Open Containing Folder",
"command.revealFileInOS.mac": "Reveal in Finder",
"command.revealFileInOS.windows": "Reveal in File Explorer",
"command.rebaseAbort": "Abort Rebase",
"command.stashIncludeUntracked": "Stash (Include Untracked)",
"command.stash": "Stash",

View file

@ -2546,6 +2546,21 @@ export class CommandCenter {
await commands.executeCommand('revealInExplorer', resourceState.resourceUri);
}
@command('git.revealFileInOS.linux')
@command('git.revealFileInOS.mac')
@command('git.revealFileInOS.windows')
async revealFileInOS(resourceState: SourceControlResourceState): Promise<void> {
if (!resourceState) {
return;
}
if (!(resourceState.resourceUri instanceof Uri)) {
return;
}
await commands.executeCommand('revealFileInOS', resourceState.resourceUri);
}
private async _stash(repository: Repository, includeUntracked = false): Promise<void> {
const noUnstagedChanges = repository.workingTreeGroup.resourceStates.length === 0
&& (!includeUntracked || repository.untrackedGroup.resourceStates.length === 0);