Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dissable button after applying fix [IDE-779] #562

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Changes from all 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
Expand Up @@ -117,7 +117,7 @@
| SetAutofixDiffsMessage
| SetAutofixErrorMessage;

const vscode = acquireVsCodeApi();

Check warning on line 120 in src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScriptLS.ts

View workflow job for this annotation

GitHub Actions / Build and Test (ubuntu-latest)

Unsafe assignment of an `any` value

Check warning on line 120 in src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScriptLS.ts

View workflow job for this annotation

GitHub Actions / Build and Test (macos-latest)

Unsafe assignment of an `any` value

Check warning on line 120 in src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScriptLS.ts

View workflow job for this annotation

GitHub Actions / Build and Test (windows-latest)

Unsafe assignment of an `any` value

function sendMessage(message: SuggestionMessage) {
vscode.postMessage(message);
Expand All @@ -138,7 +138,7 @@

sendMessage(message);
}
let suggestion: Suggestion | null = vscode.getState()?.suggestion || null;

Check warning on line 141 in src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScriptLS.ts

View workflow job for this annotation

GitHub Actions / Build and Test (ubuntu-latest)

Unsafe assignment of an `any` value

Check warning on line 141 in src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScriptLS.ts

View workflow job for this annotation

GitHub Actions / Build and Test (macos-latest)

Unsafe assignment of an `any` value

Check warning on line 141 in src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScriptLS.ts

View workflow job for this annotation

GitHub Actions / Build and Test (windows-latest)

Unsafe assignment of an `any` value

function ignoreIssue(lineOnly: boolean) {
if (!suggestion) return;
Expand Down Expand Up @@ -209,7 +209,7 @@
}

// 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;

Expand Down Expand Up @@ -248,7 +248,8 @@
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 },
Expand Down Expand Up @@ -281,16 +282,18 @@
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();
}

Expand Down
Loading