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

Commit 70c283e

Browse files
committed
Show status bar hint when using View File
Factor out `EnableNavigateStatusBarMessage` method.
1 parent 1c7bd8d commit 70c283e

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

src/GitHub.App/Services/PullRequestEditorService.cs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -466,29 +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);
471-
472-
var statusMessage = session.IsCheckedOut ?
473-
App.Resources.NavigateToEditorStatusMessage : App.Resources.NavigateToEditorNotCheckedOutStatusMessage;
474-
textView.GotAggregateFocus += (s, e) =>
475-
statusBar.ShowMessage(statusMessage);
476-
477-
textView.LostAggregateFocus += (s, e) =>
478-
statusBar.ShowMessage(string.Empty);
469+
var vsTextView = vsEditorAdaptersFactory.GetViewAdapter(textView);
470+
EnableNavigateToEditor(vsTextView, session, file);
479471
}
480472

481-
void EnableNavigateToEditor(IVsTextView textView, IPullRequestSession session, IPullRequestSessionFile file)
473+
void EnableNavigateToEditor(IVsTextView vsTextView, IPullRequestSession session, IPullRequestSessionFile file)
482474
{
483475
var commandGroup = VSConstants.CMDSETID.StandardCommandSet2K_guid;
484476
var commandId = (int)VSConstants.VSStd2KCmdID.RETURN;
485-
new TextViewCommandDispatcher(textView, commandGroup, commandId).Exec +=
477+
new TextViewCommandDispatcher(vsTextView, commandGroup, commandId).Exec +=
486478
async (s, e) => await DoNavigateToEditor(session, file);
487479

488480
var contextMenuCommandGroup = new Guid(Guids.guidContextMenuSetString);
489481
var goToCommandId = PkgCmdIDList.openFileInSolutionCommand;
490-
new TextViewCommandDispatcher(textView, contextMenuCommandGroup, goToCommandId).Exec +=
482+
new TextViewCommandDispatcher(vsTextView, contextMenuCommandGroup, goToCommandId).Exec +=
491483
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);
492500
}
493501

494502
async Task DoNavigateToEditor(IPullRequestSession session, IPullRequestSessionFile file)

0 commit comments

Comments
 (0)