Skip to content

Commit

Permalink
Merge master into feature/emr
Browse files Browse the repository at this point in the history
  • Loading branch information
aws-toolkit-automation authored Mar 11, 2025
2 parents aa88b9a + cb625e4 commit ae4b694
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 364 deletions.
9 changes: 4 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"skippedTestReport": "ts-node ./scripts/skippedTestReport.ts ./packages/amazonq/test/e2e/"
},
"devDependencies": {
"@aws-toolkits/telemetry": "^1.0.307",
"@aws-toolkits/telemetry": "^1.0.308",
"@playwright/browser-chromium": "^1.43.1",
"@stylistic/eslint-plugin": "^2.11.0",
"@types/he": "^1.2.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Feature",
"description": "/review: show code diff for fix preview"
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ export class SecurityIssueHoverProvider implements vscode.HoverProvider {
* @returns The markdown string
*/
private _makeCodeBlock(code: string, language?: string) {
const lines = code.replaceAll('\n\\ No newline at end of file', '').split('\n')
const lines = code
.replaceAll('\n\\ No newline at end of file', '')
.replaceAll('--- buggyCode\n', '')
.replaceAll('+++ fixCode\n', '')
.split('\n')
const maxLineChars = lines.reduce((acc, curr) => Math.max(acc, curr.length), 0)
const paddedLines = lines.map((line) => line.padEnd(maxLineChars + 2))

Expand Down
24 changes: 3 additions & 21 deletions packages/core/src/codewhisperer/views/securityIssue/vue/root.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ import highSeverity from '../../../../../resources/images/severity-high.svg'
import criticalSeverity from '../../../../../resources/images/severity-critical.svg'
import markdownIt from 'markdown-it'
import hljs from 'highlight.js'
import { parsePatch } from 'diff'
import { CodeScanIssue } from '../../../models/model'
const client = WebviewClientFactory.create<SecurityIssueWebview>()
Expand Down Expand Up @@ -344,28 +343,11 @@ export default defineComponent({
if (!this.isFixAvailable) {
return
}
const [parsedDiff] = parsePatch(this.suggestedFix)
const { oldStart } = parsedDiff.hunks[0]
const [referenceStart, referenceEnd] = this.referenceSpan
const htmlString = md.render(`
\`\`\`${this.languageId} showLineNumbers startFrom=${oldStart} ${
referenceStart && referenceEnd
? `highlightStart=${referenceStart + 1} highlightEnd=${referenceEnd + 1}`
: ''
}
${this.fixedCode}
return md.render(`
\`\`\`${this.languageId}
${this.suggestedFix.replaceAll('--- buggyCode\n', '').replaceAll('+++ fixCode\n', '')}
\`\`\`
`)
const parser = new DOMParser()
const doc = parser.parseFromString(htmlString, 'text/html')
const referenceTracker = doc.querySelector('.reference-tracker')
if (referenceTracker) {
const tooltip = doc.createElement('div')
tooltip.classList.add('tooltip')
tooltip.innerHTML = this.referenceText
referenceTracker.appendChild(tooltip)
}
return doc.body.innerHTML
},
scrollTo(refName: string) {
this.$nextTick(() => this.$refs?.[refName]?.scrollIntoView({ behavior: 'smooth' }))
Expand Down
Loading

0 comments on commit ae4b694

Please sign in to comment.