Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/GitHub.App/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/GitHub.App/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,13 @@ https://git-scm.com/download/win</value>
<data name="InProgress" xml:space="preserve">
<value>InProgress</value>
</data>
<data name="NavigateToEditorStatusMessage" xml:space="preserve">
<value>Press Enter to navigate to Editor</value>
</data>
<data name="NavigateToEditorNotCheckedOutInfoMessage" xml:space="preserve">
<value>Checkout PR branch before navigating to Editor</value>
</data>
<data name="NavigateToEditorNotCheckedOutStatusMessage" xml:space="preserve">
<value>Press Enter to navigate to Editor (PR branch must be checked out)</value>
</data>
</root>
28 changes: 22 additions & 6 deletions src/GitHub.App/Services/PullRequestEditorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -466,21 +466,37 @@ void AddBufferTag(

void EnableNavigateToEditor(ITextView textView, IPullRequestSession session, IPullRequestSessionFile file)
{
var view = vsEditorAdaptersFactory.GetViewAdapter(textView);
EnableNavigateToEditor(view, session, file);
var vsTextView = vsEditorAdaptersFactory.GetViewAdapter(textView);
EnableNavigateToEditor(vsTextView, session, file);
}

void EnableNavigateToEditor(IVsTextView textView, IPullRequestSession session, IPullRequestSessionFile file)
void EnableNavigateToEditor(IVsTextView vsTextView, IPullRequestSession session, IPullRequestSessionFile file)
{
var commandGroup = VSConstants.CMDSETID.StandardCommandSet2K_guid;
var commandId = (int)VSConstants.VSStd2KCmdID.RETURN;
new TextViewCommandDispatcher(textView, commandGroup, commandId).Exec +=
new TextViewCommandDispatcher(vsTextView, commandGroup, commandId).Exec +=
async (s, e) => await DoNavigateToEditor(session, file);

var contextMenuCommandGroup = new Guid(Guids.guidContextMenuSetString);
var goToCommandId = PkgCmdIDList.openFileInSolutionCommand;
new TextViewCommandDispatcher(textView, contextMenuCommandGroup, goToCommandId).Exec +=
new TextViewCommandDispatcher(vsTextView, contextMenuCommandGroup, goToCommandId).Exec +=
async (s, e) => await DoNavigateToEditor(session, file);

EnableNavigateStatusBarMessage(vsTextView, session);
}

void EnableNavigateStatusBarMessage(IVsTextView vsTextView, IPullRequestSession session)
{
var textView = vsEditorAdaptersFactory.GetWpfTextView(vsTextView);

var statusMessage = session.IsCheckedOut ?
App.Resources.NavigateToEditorStatusMessage : App.Resources.NavigateToEditorNotCheckedOutStatusMessage;

textView.GotAggregateFocus += (s, e) =>
statusBar.ShowMessage(statusMessage);

textView.LostAggregateFocus += (s, e) =>
statusBar.ShowMessage(string.Empty);
}

async Task DoNavigateToEditor(IPullRequestSession session, IPullRequestSessionFile file)
Expand All @@ -489,7 +505,7 @@ async Task DoNavigateToEditor(IPullRequestSession session, IPullRequestSessionFi
{
if (!session.IsCheckedOut)
{
ShowInfoMessage("Checkout PR branch before opening file in solution.");
ShowInfoMessage(App.Resources.NavigateToEditorNotCheckedOutInfoMessage);
return;
}

Expand Down