Skip to content

Commit c397f41

Browse files
authored
fix(amazonq): duplicate hover for project scans aws#4866
Problem Duplicate hover and code actions are appearing for project scans because only the active file's issues are getting replaced. Solution Update every security recommendation by file path instead of only the active file.
1 parent 79b5a90 commit c397f41

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

packages/core/src/codewhisperer/commands/startSecurityScan.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ export function showSecurityScanResults(
269269
void vscode.commands.executeCommand('workbench.action.problems.focus')
270270
}
271271
}
272-
populateCodeScanLogStream(zipMetadata.scannedFiles)
273272
if (scope === CodeWhispererConstants.CodeAnalysisScope.PROJECT) {
273+
populateCodeScanLogStream(zipMetadata.scannedFiles)
274274
showScanCompletedNotification(totalIssues, zipMetadata.scannedFiles, false)
275275
}
276276
}

packages/core/src/codewhisperer/service/diagnosticsProvider.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,18 @@ export function initSecurityScanRender(
3636
}
3737
securityRecommendationList.forEach(securityRecommendation => {
3838
updateSecurityDiagnosticCollection(securityRecommendation)
39+
updateSecurityIssueHoverAndCodeActions(securityRecommendation)
3940
})
4041
securityScanRender.initialized = true
41-
updateSecurityIssueHoverAndCodeActions(securityRecommendationList, editor)
4242
securityScanRender.lastUpdated = codeScanStartTime
4343
}
4444

45-
function updateSecurityIssueHoverAndCodeActions(
46-
securityRecommendationList: AggregatedCodeScanIssue[],
47-
editor: vscode.TextEditor
48-
) {
45+
function updateSecurityIssueHoverAndCodeActions(securityRecommendation: AggregatedCodeScanIssue) {
4946
const updatedSecurityRecommendationList = [
50-
...SecurityIssueHoverProvider.instance.issues.filter(group => group.filePath !== editor.document.uri.fsPath),
51-
...securityRecommendationList,
47+
...SecurityIssueHoverProvider.instance.issues.filter(
48+
group => group.filePath !== securityRecommendation.filePath
49+
),
50+
securityRecommendation,
5251
]
5352
SecurityIssueHoverProvider.instance.issues = updatedSecurityRecommendationList
5453
SecurityIssueCodeActionProvider.instance.issues = updatedSecurityRecommendationList

0 commit comments

Comments
 (0)