Skip to content

Commit 560c837

Browse files
Hover on first line only
1 parent 41b9db6 commit 560c837

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

ast-visual-studio-extension/CxExtension/CxAssist/Core/Markers/CxAssistAsyncQuickInfoSource.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,43 @@ public async Task<QuickInfoItem> GetQuickInfoItemAsync(IAsyncQuickInfoSession se
7474
if (issuesOnly.Count == 0)
7575
return null;
7676

77+
// If any vulnerability spans multiple lines: only show popover on the first line
78+
var hasMultiLineVuln = issuesOnly.Any(v =>
79+
(v.Locations != null && v.Locations.Count > 1) ||
80+
(v.EndLineNumber > 0 && v.EndLineNumber > v.LineNumber));
81+
82+
if (hasMultiLineVuln)
83+
{
84+
foreach (var vuln in issuesOnly)
85+
{
86+
// Check if this specific vulnerability is multi-line
87+
bool isMultiLine = (vuln.Locations != null && vuln.Locations.Count > 1) ||
88+
(vuln.EndLineNumber > 0 && vuln.EndLineNumber > vuln.LineNumber);
89+
90+
if (isMultiLine)
91+
{
92+
// Determine the actual first line of this multi-line vulnerability
93+
int actualFirstLine = vuln.LineNumber;
94+
95+
if (vuln.Locations != null && vuln.Locations.Count > 0)
96+
{
97+
var firstLocation = vuln.Locations.OrderBy(l => l.Line).FirstOrDefault();
98+
if (firstLocation != null)
99+
{
100+
actualFirstLine = firstLocation.Line;
101+
}
102+
}
103+
104+
// Only show popover one line prior to the actual first line
105+
int targetLine = actualFirstLine - 1;
106+
if (lineNumber != targetLine)
107+
{
108+
return null;
109+
}
110+
}
111+
}
112+
}
113+
77114
// Only one of our sources (per session) should contribute; avoid duplicate blocks when multiple subject buffers exist.
78115
lock (_sessionLock)
79116
{

0 commit comments

Comments
 (0)