Skip to content

Commit 842a9c7

Browse files
committed
Allows revealing all WIP nodes in file explorer
- Enables the "Reveal in Explorer" command for all WIP rows, not just those explicitly marked as worktrees - Falls back to using the repository path for the primary WIP row when no specific worktree is resolved - Hides the menu option when virtual folders are present, where local file exploration is unsupported
1 parent 5a0d93c commit 842a9c7

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

contributions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3725,7 +3725,7 @@
37253725
"menus": {
37263726
"webview/context": [
37273727
{
3728-
"when": "webviewItem =~ /^gitlens:wip\\b(?=.*?\\b\\+worktree\\b)/ && !listMultiSelection",
3728+
"when": "webviewItem =~ /^gitlens:wip\\b/ && !listMultiSelection && !gitlens:hasVirtualFolders",
37293729
"group": "0_gitlens_worktree_1",
37303730
"order": 1
37313731
},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27135,7 +27135,7 @@
2713527135
},
2713627136
{
2713727137
"command": "gitlens.graph.revealWorktreeInExplorer",
27138-
"when": "webviewItem =~ /^gitlens:wip\\b(?=.*?\\b\\+worktree\\b)/ && !listMultiSelection",
27138+
"when": "webviewItem =~ /^gitlens:wip\\b/ && !listMultiSelection && !gitlens:hasVirtualFolders",
2713927139
"group": "0_gitlens_worktree_1@1"
2714027140
},
2714127141
{

src/webviews/plus/graph/graphWebview.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10801,12 +10801,21 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
1080110801
@debug()
1080210802
private async revealWorktreeInExplorer(item?: GraphItemContext) {
1080310803
const worktree = await this.getGraphItemWorktree(item);
10804-
if (worktree == null) return;
10804+
// worktree.uri preserves remote-dev schemes for branch/secondary-worktree contexts.
10805+
let uri = worktree?.uri;
10806+
if (uri == null) {
10807+
// Primary WIP has no resolved worktree (getGraphItemWorktree returns undefined to protect
10808+
// explainWip); reveal the row's own repo folder, mirroring openInIntegratedTerminal.
10809+
const ref = this.getGraphItemRef(item, 'revision');
10810+
if (ref?.ref !== uncommitted) return;
10811+
10812+
uri = Uri.file(ref.repoPath);
10813+
}
1080510814

1080610815
// Pass a sub-path (.git always exists in any worktree) so the OS file manager opens the
1080710816
// worktree folder itself rather than its parent — the default `revealFileInOS` selects
1080810817
// the folder in the parent on Windows/WSL, which isn't what users expect for a worktree.
10809-
void revealInFileExplorer(Uri.joinPath(worktree.uri, '.git'));
10818+
void revealInFileExplorer(Uri.joinPath(uri, '.git'));
1081010819
}
1081110820

1081210821
@command('gitlens.graph.deleteWorktree')

0 commit comments

Comments
 (0)