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

Commit c2b105e

Browse files
authored
Merge pull request #1552 from github/fixes/1546-make-navigate-to-editor-discoverable
Make Navigate to Editor more discoverable
2 parents 4174562 + 70c283e commit c2b105e

File tree

3 files changed

+58
-6
lines changed

3 files changed

+58
-6
lines changed

src/GitHub.App/Resources.Designer.cs

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/GitHub.App/Resources.resx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,4 +306,13 @@ https://git-scm.com/download/win</value>
306306
<data name="InProgress" xml:space="preserve">
307307
<value>InProgress</value>
308308
</data>
309+
<data name="NavigateToEditorStatusMessage" xml:space="preserve">
310+
<value>Press Enter to navigate to Editor</value>
311+
</data>
312+
<data name="NavigateToEditorNotCheckedOutInfoMessage" xml:space="preserve">
313+
<value>Checkout PR branch before navigating to Editor</value>
314+
</data>
315+
<data name="NavigateToEditorNotCheckedOutStatusMessage" xml:space="preserve">
316+
<value>Press Enter to navigate to Editor (PR branch must be checked out)</value>
317+
</data>
309318
</root>

src/GitHub.App/Services/PullRequestEditorService.cs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -466,21 +466,37 @@ void AddBufferTag(
466466

467467
void EnableNavigateToEditor(ITextView textView, IPullRequestSession session, IPullRequestSessionFile file)
468468
{
469-
var view = vsEditorAdaptersFactory.GetViewAdapter(textView);
470-
EnableNavigateToEditor(view, session, file);
469+
var vsTextView = vsEditorAdaptersFactory.GetViewAdapter(textView);
470+
EnableNavigateToEditor(vsTextView, session, file);
471471
}
472472

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

480480
var contextMenuCommandGroup = new Guid(Guids.guidContextMenuSetString);
481481
var goToCommandId = PkgCmdIDList.openFileInSolutionCommand;
482-
new TextViewCommandDispatcher(textView, contextMenuCommandGroup, goToCommandId).Exec +=
482+
new TextViewCommandDispatcher(vsTextView, contextMenuCommandGroup, goToCommandId).Exec +=
483483
async (s, e) => await DoNavigateToEditor(session, file);
484+
485+
EnableNavigateStatusBarMessage(vsTextView, session);
486+
}
487+
488+
void EnableNavigateStatusBarMessage(IVsTextView vsTextView, IPullRequestSession session)
489+
{
490+
var textView = vsEditorAdaptersFactory.GetWpfTextView(vsTextView);
491+
492+
var statusMessage = session.IsCheckedOut ?
493+
App.Resources.NavigateToEditorStatusMessage : App.Resources.NavigateToEditorNotCheckedOutStatusMessage;
494+
495+
textView.GotAggregateFocus += (s, e) =>
496+
statusBar.ShowMessage(statusMessage);
497+
498+
textView.LostAggregateFocus += (s, e) =>
499+
statusBar.ShowMessage(string.Empty);
484500
}
485501

486502
async Task DoNavigateToEditor(IPullRequestSession session, IPullRequestSessionFile file)
@@ -489,7 +505,7 @@ async Task DoNavigateToEditor(IPullRequestSession session, IPullRequestSessionFi
489505
{
490506
if (!session.IsCheckedOut)
491507
{
492-
ShowInfoMessage("Checkout PR branch before opening file in solution.");
508+
ShowInfoMessage(App.Resources.NavigateToEditorNotCheckedOutInfoMessage);
493509
return;
494510
}
495511

0 commit comments

Comments
 (0)