From 7061cb36e78a79168209c9bc0831bdfdbc5172c4 Mon Sep 17 00:00:00 2001 From: Bastian Doetsch Date: Thu, 14 Mar 2024 11:51:51 +0100 Subject: [PATCH 1/2] fix: set diffs to panel --- .../snykCode/views/suggestion/codeSuggestionWebviewProvider.ts | 3 +-- .../snykCode/views/suggestion/codeSuggestionWebviewScript.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewProvider.ts b/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewProvider.ts index 89c033d6c..a0338fd7c 100644 --- a/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewProvider.ts +++ b/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewProvider.ts @@ -229,7 +229,6 @@ export class CodeSuggestionWebviewProvider } case 'getAutofixDiffs': { const suggestion = args.suggestion as Suggestion - // const vscodeUri = vscode.Uri.file(uri); console.log('getAutofixDiffs', suggestion.folderPath, suggestion.uri, this.openIssueId); // TODO remove const diffs: AutofixUnifiedDiffSuggestion = await vscode.commands.executeCommand( SNYK_CODE_FIX_DIFFS_COMMAND, @@ -238,7 +237,7 @@ export class CodeSuggestionWebviewProvider this.openIssueId, ); console.log('posting diffs', diffs); // TODO remove - void this.panel?.webview.postMessage({ type: 'setAutofixDiff', args: diffs }); + void this.panel?.webview.postMessage({ type: 'setAutofixDiffs', args: diffs }); break; } default: { diff --git a/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScript.ts b/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScript.ts index 788a7b191..c1057b225 100644 --- a/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScript.ts +++ b/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScript.ts @@ -552,7 +552,7 @@ declare const acquireVsCodeApi: any; } sendMessage(message) toggleLoading("hide"); - }, 1500); + }, 15000); } function sendMessage(message: { From b086043e2256152c01f272d7a0badeef2e6ddf19 Mon Sep 17 00:00:00 2001 From: Michael Aquilina Date: Fri, 15 Mar 2024 17:44:31 +0000 Subject: [PATCH 2/2] fix: generate correct folderPath and filePath --- .../views/suggestion/codeSuggestionWebviewProvider.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewProvider.ts b/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewProvider.ts index a0338fd7c..017a644bd 100644 --- a/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewProvider.ts +++ b/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewProvider.ts @@ -165,23 +165,21 @@ export class CodeSuggestionWebviewProvider // get the workspace folders // look at the filepath and identify the folder that contains the filepath let workspaceFolder = "" - for (let i = 0; i < this.workspace.getWorkspaceFolders.length; i++) { - const element = this.workspace.getWorkspaceFolders[i]; + for (const element of this.workspace.getWorkspaceFolders()) { if (issue.filePath.startsWith(element)){ workspaceFolder = element; break } } - this.workspace.getWorkspaceFolders return { id: issue.id, title: issue.title, - uri: issue.filePath, + uri: issue.filePath.replace(workspaceFolder + "/", ""), severity: _.capitalize(issue.severity), ...issue.additionalData, text: parsedDetails, hasAIFix: issue.additionalData.hasAIFix, - folderPath: workspaceFolder + folderPath: workspaceFolder, }; }