diff --git a/package.json b/package.json index 473503f..ee8dbcf 100644 --- a/package.json +++ b/package.json @@ -12964,9 +12964,15 @@ "group": "1_gitlens_actions@2" }, { + "command": "gitlens.openComparisonOnRemote", + "when": "viewItem =~ /gitlens:compare:results(?!:)\\b/", + "group": "2_gitlens_quickopen@1 && gitlens:hasRemotes", + "alt": "gitlens.copyRemoteComparisonUrl" + }, + { "command": "gitlens.views.openDirectoryDiff", "when": "viewItem =~ /gitlens:compare:results(?!:)\\b/", - "group": "2_gitlens_quickopen@1" + "group": "2_gitlens_quickopen@2" }, { "command": "gitlens.views.setResultsCommitsFilterOff", @@ -12990,13 +12996,13 @@ }, { "command": "gitlens.openComparisonOnRemote", - "when": "viewItem =~ /gitlens:compare:results:commits\\b/", + "when": "viewItem =~ /gitlens:compare:results:commits\\b/ && gitlens:hasRemotes", "group": "inline@99", "alt": "gitlens.copyRemoteComparisonUrl" }, { "command": "gitlens.openComparisonOnRemote", - "when": "viewItem =~ /gitlens:compare:results:commits\\b/", + "when": "viewItem =~ /gitlens:compare:results:commits\\b/ && gitlens:hasRemotes", "group": "3_gitlens_explore@0", "alt": "gitlens.copyRemoteComparisonUrl" }, diff --git a/src/commands/openComparisonOnRemote.ts b/src/commands/openComparisonOnRemote.ts index 00c4ca4..90a9dd7 100644 --- a/src/commands/openComparisonOnRemote.ts +++ b/src/commands/openComparisonOnRemote.ts @@ -4,7 +4,6 @@ import { RemoteResourceType } from '../git/models/remoteResource'; import { showGenericErrorMessage } from '../messages'; import { command, executeCommand } from '../system/command'; import { Logger } from '../system/logger'; -import { ResultsCommitsNode } from '../views/nodes/resultsCommitsNode'; import type { CommandContext } from './base'; import { Command } from './base'; import type { OpenOnRemoteCommandArgs } from './openOnRemote'; @@ -25,13 +24,20 @@ export class OpenComparisonOnRemoteCommand extends Command { protected override preExecute(context: CommandContext, args?: OpenComparisonOnRemoteCommandArgs) { if (context.type === 'viewItem') { - if (context.node instanceof ResultsCommitsNode) { + if (context.node.is('results-commits')) { args = { ...args, repoPath: context.node.repoPath, ref1: context.node.ref1, ref2: context.node.ref2, }; + } else if (context.node.is('compare-results')) { + args = { + ...args, + repoPath: context.node.repoPath, + ref1: context.node.ahead.ref1, + ref2: context.node.ahead.ref2, + }; } } diff --git a/src/views/nodes/viewNode.ts b/src/views/nodes/viewNode.ts index 18112a2..d088f2e 100644 --- a/src/views/nodes/viewNode.ts +++ b/src/views/nodes/viewNode.ts @@ -47,6 +47,7 @@ import type { FolderNode } from './folderNode'; import type { LineHistoryTrackerNode } from './lineHistoryTrackerNode'; import type { MergeConflictFileNode } from './mergeConflictFileNode'; import type { RepositoryNode } from './repositoryNode'; +import type { ResultsCommitsNode } from './resultsCommitsNode'; import type { ResultsFileNode } from './resultsFileNode'; import type { StashFileNode } from './stashFileNode'; import type { StashNode } from './stashNode'; @@ -857,6 +858,8 @@ type TreeViewNodesByType = { ? RepositoryNode : T extends 'repo-folder' ? RepositoryFolderNode + : T extends 'results-commits' + ? ResultsCommitsNode : T extends 'results-file' ? ResultsFileNode : T extends 'stash'