From 6bff18c66d2545d99db80ed7aaa7c97f1ae875d8 Mon Sep 17 00:00:00 2001 From: Zdroba <72391375+DariusZdroba@users.noreply.github.com> Date: Fri, 6 Dec 2024 14:52:56 +0200 Subject: [PATCH] fix: dissable button after applying fix [IDE-779] (#562) * fix: dissable button after applying fix * chore: lint --- .../views/suggestion/codeSuggestionWebviewScriptLS.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScriptLS.ts b/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScriptLS.ts index e63d738a0..8d1aceaf0 100644 --- a/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScriptLS.ts +++ b/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScriptLS.ts @@ -209,7 +209,7 @@ declare const acquireVsCodeApi: any; } // different AI fix buttons - const applyFixButton = document.getElementById('apply-fix') as HTMLElement; + const applyFixButton = document.getElementById('apply-fix') as HTMLButtonElement; const retryGenerateFixButton = document.getElementById('retry-generate-fix') as HTMLElement; const generateAIFixButton = document.getElementById('generate-ai-fix') as HTMLElement; @@ -248,7 +248,8 @@ declare const acquireVsCodeApi: any; const filePath = suggestion.filePath; const patch = diffSuggestion.unifiedDiffsPerFile[filePath]; const fixId = diffSuggestion.fixId; - + lastAppliedFix = diffSelectedIndex; + applyFixButton.disabled = true; const message: ApplyGitDiffMessage = { type: 'applyGitDiff', args: { filePath, patch, fixId }, @@ -281,16 +282,18 @@ declare const acquireVsCodeApi: any; const diffNum2Elem = document.getElementById('diff-number2') as HTMLElement; let diffSelectedIndex = 0; - + let lastAppliedFix = -1; function nextDiff() { if (!suggestion || !suggestion.diffs || diffSelectedIndex >= suggestion.diffs.length - 1) return; ++diffSelectedIndex; + applyFixButton.disabled = diffSelectedIndex == lastAppliedFix; showCurrentDiff(); } function previousDiff() { if (!suggestion || !suggestion.diffs || diffSelectedIndex <= 0) return; --diffSelectedIndex; + applyFixButton.disabled = diffSelectedIndex == lastAppliedFix; showCurrentDiff(); }