Skip to content

Commit b76e063

Browse files
committed
fix(gutter): use tracked tooltip line for click handler
1 parent 0b3234f commit b76e063

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/CodingWithCalvin.GitRanger/Editor/GutterMargin/BlameMargin.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,17 +317,19 @@ private void DrawLineIndicator(
317317

318318
private void OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
319319
{
320-
var position = e.GetPosition(this);
321-
var blameInfo = GetBlameInfoAtPosition(position);
322-
if (blameInfo != null)
320+
// Use the current tooltip line since we already know it has blame data
321+
if (_currentTooltipLine > 0)
323322
{
324-
// Show commit details
325-
System.Windows.Clipboard.SetText(blameInfo.CommitSha);
326-
ThreadHelper.JoinableTaskFactory.RunAsync(async () =>
323+
var blameInfo = _blameData.FirstOrDefault(b => b.LineNumber == _currentTooltipLine);
324+
if (blameInfo != null)
327325
{
328-
await Community.VisualStudio.Toolkit.VS.StatusBar.ShowMessageAsync(
329-
$"Git Ranger: Copied commit SHA {blameInfo.ShortSha} to clipboard");
330-
});
326+
System.Windows.Clipboard.SetText(blameInfo.CommitSha);
327+
ThreadHelper.JoinableTaskFactory.RunAsync(async () =>
328+
{
329+
await Community.VisualStudio.Toolkit.VS.StatusBar.ShowMessageAsync(
330+
$"Git Ranger: Copied commit SHA {blameInfo.ShortSha} to clipboard");
331+
});
332+
}
331333
}
332334
}
333335

0 commit comments

Comments
 (0)