Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Bug Fix",
"description": "fix bug where code fix line number or file was not accurate"
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { TelemetryHelper } from '../util/telemetryHelper'
import { tempDirPath } from '../../shared/filesystemUtilities'
import { CodeWhispererSettings } from '../util/codewhispererSettings'
import { AuthUtil } from '../util/authUtil'
import { saveDocumentIfDirty } from '../../shared/utilities/textDocumentUtilities'

export async function startCodeFixGeneration(
client: DefaultCodeWhispererClient,
Expand All @@ -44,6 +45,9 @@ export async function startCodeFixGeneration(
* Step 1: Generate zip
*/
throwIfCancelled()

// Save the file if it has unsaved changes to ensure the latest content is included in the zip
await saveDocumentIfDirty(filePath)
const admZip = new AdmZip()
admZip.addLocalFile(filePath)

Expand Down
13 changes: 7 additions & 6 deletions packages/core/src/codewhisperer/service/securityIssueProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ export class SecurityIssueProvider {
...group,
issues: group.issues
.filter((issue) => {
const range = new vscode.Range(
issue.startLine,
event.document.lineAt(issue.startLine)?.range.start.character ?? 0,
issue.endLine,
event.document.lineAt(issue.endLine - 1)?.range.end.character ?? 0
)
let range
if (issue.startLine === issue.endLine) {
range = new vscode.Range(issue.startLine, 0, issue.endLine + 1, 0)
} else {
range = new vscode.Range(issue.startLine, 0, issue.endLine, 0)
}

const intersection = changedRange.intersection(range)
return !(intersection && (/\S/.test(changedText) || changedText === ''))
})
Expand Down
Loading