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

Commit 5e2cbfd

Browse files
committed
Only track comment bubbles with mouse on diff view
1 parent 8c6bd29 commit 5e2cbfd

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/GitHub.InlineReviews/InlineCommentMarginProvider.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Windows;
23
using System.Windows.Controls;
34
using System.ComponentModel.Composition;
45
using Microsoft.VisualStudio.Utilities;
@@ -10,7 +11,6 @@
1011
using GitHub.InlineReviews.Glyph;
1112
using GitHub.InlineReviews.Services;
1213
using GitHub.InlineReviews.Views;
13-
using GitHub.Models;
1414
using GitHub.Services;
1515

1616
namespace GitHub.InlineReviews
@@ -61,13 +61,20 @@ IWpfTextViewMargin CreateMargin<TGlyphTag>(IGlyphFactory<TGlyphTag> glyphFactory
6161
var margin = new GlyphMargin<TGlyphTag>(wpfTextViewHost, glyphFactory, gridFactory, tagAggregator, editorFormatMap,
6262
IsMarginVisible, MarginPropertiesName, MarginName, true, 17.0);
6363

64-
var router = new MouseEnterAndLeaveEventRouter<AddInlineCommentGlyph>();
65-
wpfTextViewHost.TextView.VisualElement.MouseMove += (t, e) => router.MouseMove(margin.VisualElement, e);
66-
wpfTextViewHost.TextView.VisualElement.MouseLeave += (t, e) => router.MouseLeave(margin.VisualElement, e);
67-
64+
TrackCommentGlyphOnDiffView(wpfTextViewHost.TextView, margin.VisualElement);
6865
return margin;
6966
}
7067

68+
void TrackCommentGlyphOnDiffView(IWpfTextView textView, FrameworkElement visualElement)
69+
{
70+
if (textView.Roles.Contains("DIFF"))
71+
{
72+
var router = new MouseEnterAndLeaveEventRouter<AddInlineCommentGlyph>();
73+
textView.VisualElement.MouseMove += (t, e) => router.MouseMove(visualElement, e);
74+
textView.VisualElement.MouseLeave += (t, e) => router.MouseLeave(visualElement, e);
75+
}
76+
}
77+
7178
bool IsMarginVisible(ITextBuffer buffer)
7279
{
7380
if (sessionManager.GetTextBufferInfo(buffer) != null)

0 commit comments

Comments
 (0)