Browse Source

Adds reveal in file explorer to worktrees

main
Eric Amodio 2 years ago
parent
commit
cf31232c64
4 changed files with 30 additions and 2 deletions
  1. +14
    -0
      package.json
  2. +6
    -2
      src/commands/gitCommands.actions.ts
  3. +2
    -0
      src/constants.ts
  4. +8
    -0
      src/views/viewCommands.ts

+ 14
- 0
package.json View File

@ -4861,6 +4861,11 @@
"icon": "$(empty-window)"
},
{
"command": "gitlens.views.revealWorktreeInExplorer",
"title": "Reveal Worktree in File Explorer",
"category": "GitLens"
},
{
"command": "gitlens.views.cherryPick",
"title": "Cherry Pick Commit...",
"category": "GitLens"
@ -6652,6 +6657,10 @@
"when": "false"
},
{
"command": "gitlens.views.revealWorktreeInExplorer",
"when": "false"
},
{
"command": "gitlens.views.createBranch",
"when": "false"
},
@ -9542,6 +9551,11 @@
"group": "2_gitlens_quickopen@2"
},
{
"command": "gitlens.views.revealWorktreeInExplorer",
"when": "viewItem =~ /gitlens:worktree\\b/",
"group": "3_gitlens@1"
},
{
"command": "gitlens.views.deleteWorktree",
"when": "!gitlens:readonly && viewItem =~ /gitlens:worktree\\b(?!.*?\\b\\+(active|main)\\b)/",
"group": "6_gitlens_actions@1"

+ 6
- 2
src/commands/gitCommands.actions.ts View File

@ -7,7 +7,7 @@ import type {
OpenWorkingFileCommandArgs,
} from '../commands';
import { FileAnnotationType } from '../configuration';
import { Commands } from '../constants';
import { Commands, CoreCommands } from '../constants';
import { Container } from '../container';
import { GitUri } from '../git/gitUri';
import {
@ -26,7 +26,7 @@ import {
} from '../git/models';
import { RepositoryPicker } from '../quickpicks/repositoryPicker';
import { ensure } from '../system/array';
import { executeCommand, executeEditorCommand } from '../system/command';
import { executeCommand, executeCoreCommand, executeEditorCommand } from '../system/command';
import { findOrOpenEditor, findOrOpenEditors, openWorkspace, OpenWorkspaceLocation } from '../system/utils';
import { ViewsWithRepositoryFolders } from '../views/viewBase';
import { ResetGitCommandArgs } from './git/reset';
@ -915,5 +915,9 @@ export namespace GitActions {
: await Container.instance.repositoriesView.revealWorktree(worktree, options);
return node;
}
export async function revealInFileExplorer(worktree: GitWorktree) {
void (await executeCoreCommand(CoreCommands.RevealInFileExplorer, worktree.uri));
}
}
}

+ 2
- 0
src/constants.ts View File

@ -266,6 +266,8 @@ export const enum CoreCommands {
NextEditor = 'workbench.action.nextEditor',
PreviewHtml = 'vscode.previewHtml',
RevealLine = 'revealLine',
RevealInExplorer = 'revealInExplorer',
RevealInFileExplorer = 'revealFileInOS',
SetContext = 'setContext',
ShowExplorer = 'workbench.view.explorer',
ShowReferences = 'editor.action.showReferences',

+ 8
- 0
src/views/viewCommands.ts View File

@ -232,6 +232,7 @@ export class ViewCommands {
commands.registerCommand('gitlens.views.createWorktree', this.createWorktree, this);
commands.registerCommand('gitlens.views.deleteWorktree', this.deleteWorktree, this);
commands.registerCommand('gitlens.views.openWorktree', this.openWorktree, this);
commands.registerCommand('gitlens.views.revealWorktreeInExplorer', this.revealWorktreeInExplorer, this);
commands.registerCommand(
'gitlens.views.openWorktreeInNewWindow',
n => this.openWorktree(n, { location: OpenWorkspaceLocation.NewWindow }),
@ -329,6 +330,13 @@ export class ViewCommands {
}
@debug()
private revealWorktreeInExplorer(node: WorktreeNode) {
if (!(node instanceof WorktreeNode)) return undefined;
return GitActions.Worktree.revealInFileExplorer(node.worktree);
}
@debug()
private async deleteWorktree(node: WorktreeNode) {
if (!(node instanceof WorktreeNode)) return undefined;

Loading…
Cancel
Save