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

Commit b3ac6c6

Browse files
authored
Merge pull request #1157 from github/fixes/1154-fix-links-in-inline-comments
Fix links in inline comments.
2 parents aa1fbbb + 6399a34 commit b3ac6c6

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/GitHub.InlineReviews/Views/CommentView.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
</ResourceDictionary>
3333
</FrameworkElement.Resources>
3434

35+
<FrameworkElement.CommandBindings>
36+
<CommandBinding Command="{x:Static markdig:Commands.Hyperlink}" Executed="OpenHyperlink" />
37+
</FrameworkElement.CommandBindings>
38+
3539
<Grid>
3640
<!-- Displays an existing comment-->
3741
<StackPanel Orientation="Vertical" Margin="4">

src/GitHub.InlineReviews/Views/CommentView.xaml.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Windows.Controls;
3+
using System.Windows.Input;
34
using System.Windows.Threading;
45
using GitHub.InlineReviews.ViewModels;
56
using GitHub.Services;
@@ -23,11 +24,15 @@ public CommentView()
2324
});
2425
}
2526

26-
void DoOpenOnGitHub()
27+
IVisualStudioBrowser GetBrowser()
2728
{
2829
var serviceProvider = (IGitHubServiceProvider)Package.GetGlobalService(typeof(IGitHubServiceProvider));
29-
var browser = serviceProvider.GetService<IVisualStudioBrowser>();
30-
browser.OpenUrl(ViewModel.Thread.GetCommentUrl(ViewModel.Id));
30+
return serviceProvider.GetService<IVisualStudioBrowser>();
31+
}
32+
33+
void DoOpenOnGitHub()
34+
{
35+
GetBrowser().OpenUrl(ViewModel.Thread.GetCommentUrl(ViewModel.Id));
3136
}
3237

3338
private void CommentView_Loaded(object sender, System.Windows.RoutedEventArgs e)
@@ -56,5 +61,15 @@ private void buttonPanel_IsVisibleChanged(object sender, System.Windows.Dependen
5661
BringIntoView();
5762
}
5863
}
64+
65+
void OpenHyperlink(object sender, ExecutedRoutedEventArgs e)
66+
{
67+
Uri uri;
68+
69+
if (Uri.TryCreate(e.Parameter?.ToString(), UriKind.Absolute, out uri))
70+
{
71+
GetBrowser().OpenUrl(uri);
72+
}
73+
}
5974
}
6075
}

0 commit comments

Comments
 (0)