Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 448ec65

Browse files
committed
Add Open File in Solution context menu item
Added to `GitHub` submenu, but this isn't very discoverable.
1 parent 8c538df commit 448ec65

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

src/GitHub.Exports/Settings/PkgCmdID.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public static class PkgCmdIDList
1717
public const int createGistCommand = 0x400;
1818
public const int openLinkCommand = 0x100;
1919
public const int copyLinkCommand = 0x101;
20+
public const int openFileInSolutionCommand = 0x102;
2021
public const int githubCommand = 0x320;
2122
public const int helpCommand = 0x321;
2223
public const int blameCommand = 0x500;

src/GitHub.VisualStudio/GitHub.VisualStudio.vsct

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,16 @@
191191
<ButtonText>Blame</ButtonText>
192192
</Strings>
193193
</Button>
194+
195+
<Button guid="guidContextMenuSet" id="openFileInSolutionCommand" type="Button">
196+
<Icon guid="guidImages" id="logo" />
197+
<CommandFlag>IconIsMoniker</CommandFlag>
198+
<CommandFlag>DefaultInvisible</CommandFlag>
199+
<CommandFlag>DynamicVisibility</CommandFlag>
200+
<Strings>
201+
<ButtonText>Open File in Solution</ButtonText>
202+
</Strings>
203+
</Button>
194204

195205
</Buttons>
196206

@@ -232,6 +242,9 @@
232242
<Parent guid="guidContextMenuSet" id="idGitHubContextSubMenuGroup"/>
233243
</CommandPlacement>
234244

245+
<CommandPlacement guid="guidContextMenuSet" id="openFileInSolutionCommand" priority="0x104">
246+
<Parent guid="guidContextMenuSet" id="idGitHubContextSubMenuGroup"/>
247+
</CommandPlacement>
235248

236249
<!-- Standard toolbar commands -->
237250
<CommandPlacement guid="guidGitHubToolbarCmdSet" id="backCommand" priority="0x100">
@@ -320,9 +333,9 @@
320333
<IDSymbol name="idGitHubContextSubMenuGroup" value="0x1002" />
321334
<IDSymbol name="openLinkCommand" value="0x100" />
322335
<IDSymbol name="copyLinkCommand" value="0x101"/>
336+
<IDSymbol name="openFileInSolutionCommand" value="0x0102" />
323337
<IDSymbol name="idCreateGistCommand" value="0x0400" />
324338
<IDSymbol name="idBlameCommand" value="0x0500" />
325-
326339
</GuidSymbol>
327340

328341
<GuidSymbol name="GUID_XAML_EDITOR" value="{4C87B692-1202-46AA-B64C-EF01FAEC53DA}">

src/GitHub.VisualStudio/Views/GitHubPane/PullRequestDetailView.xaml.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,11 @@ void EnableNavigateToEditor(IVsTextView textView, IPullRequestFileNode file)
242242
{
243243
var commandGroup = VSConstants.CMDSETID.StandardCommandSet2K_guid;
244244
var commandId = (int)VSConstants.VSStd2KCmdID.RETURN;
245-
var dispatcher = new TextViewCommandDispatcher(textView, commandGroup, commandId);
246-
dispatcher.Exec += async (s, e) => await DoOpenLiveFile(file);
245+
new TextViewCommandDispatcher(textView, commandGroup, commandId).Exec += async (s, e) => await DoOpenLiveFile(file);
246+
247+
var contextMenuCommandGroup = new Guid(Guids.guidContextMenuSetString);
248+
var goToCommandId = PkgCmdIDList.openFileInSolutionCommand;
249+
new TextViewCommandDispatcher(textView, contextMenuCommandGroup, goToCommandId).Exec += async (s, e) => await DoOpenLiveFile(file);
247250
}
248251

249252
void ShowErrorInStatusBar(string message, Exception e = null)

src/GitHub.VisualStudio/Views/GitHubPane/TextViewCommandDispatcher.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ int IOleCommandTarget.Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt
3939

4040
int IOleCommandTarget.QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
4141
{
42+
if (pguidCmdGroup == commandGroup)
43+
{
44+
if (prgCmds != null && cCmds == 1)
45+
{
46+
if (prgCmds[0].cmdID == commandId)
47+
{
48+
prgCmds[0].cmdf = (uint)OLECMDF.OLECMDF_SUPPORTED | (uint)OLECMDF.OLECMDF_ENABLED;
49+
return VSConstants.S_OK;
50+
}
51+
}
52+
}
53+
4254
return next?.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText) ?? 0;
4355
}
4456

0 commit comments

Comments
 (0)