Skip to content

Commit

Permalink
fix "command not found" for code actions (#240849)
Browse files Browse the repository at this point in the history
fix code action errors
  • Loading branch information
justschen authored Feb 14, 2025
1 parent c619eb7 commit db5460c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/vs/editor/contrib/codeAction/browser/codeActionModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ export class CodeActionModel extends Disposable {
const actions = createCancelablePromise(async token => {
if (this._settingEnabledNearbyQuickfixes() && trigger.trigger.type === CodeActionTriggerType.Invoke && (trigger.trigger.triggerAction === CodeActionTriggerSource.QuickFix || trigger.trigger.filter?.include?.contains(CodeActionKind.QuickFix))) {
const codeActionSet = await getCodeActions(this._registry, model, trigger.selection, trigger.trigger, Progress.None, token);
this.codeActionsDisposable.value = codeActionSet;
const allCodeActions = [...codeActionSet.allActions];
if (token.isCancellationRequested) {
codeActionSet.dispose();
Expand All @@ -251,7 +250,7 @@ export class CodeActionModel extends Disposable {
action.action.diagnostics = [...allMarkers.filter(marker => marker.relatedInformation)];
}
}
return { validActions: codeActionSet.validActions, allActions: allCodeActions, documentation: codeActionSet.documentation, hasAutoFix: codeActionSet.hasAutoFix, hasAIFix: codeActionSet.hasAIFix, allAIFixes: codeActionSet.allAIFixes, dispose: () => { codeActionSet.dispose(); } };
return { validActions: codeActionSet.validActions, allActions: allCodeActions, documentation: codeActionSet.documentation, hasAutoFix: codeActionSet.hasAutoFix, hasAIFix: codeActionSet.hasAIFix, allAIFixes: codeActionSet.allAIFixes, dispose: () => { this.codeActionsDisposable.value = codeActionSet; } };
} else if (!foundQuickfix) {
// If markers exist, and there are no quickfixes found or length is zero, check for quickfixes on that line.
if (allMarkers.length > 0) {
Expand All @@ -278,7 +277,10 @@ export class CodeActionModel extends Disposable {

const selectionAsPosition = new Selection(trackedPosition.lineNumber, trackedPosition.column, trackedPosition.lineNumber, trackedPosition.column);
const actionsAtMarker = await getCodeActions(this._registry, model, selectionAsPosition, newCodeActionTrigger, Progress.None, token);
this.codeActionsDisposable.value = actionsAtMarker;
if (token.isCancellationRequested) {
actionsAtMarker.dispose();
return emptyCodeActionSet;
}

if (actionsAtMarker.validActions.length !== 0) {
for (const action of actionsAtMarker.validActions) {
Expand Down Expand Up @@ -319,7 +321,7 @@ export class CodeActionModel extends Disposable {
});

// Only retriggers if actually found quickfix on the same line as cursor
return { validActions: filteredActions, allActions: allCodeActions, documentation: codeActionSet.documentation, hasAutoFix: codeActionSet.hasAutoFix, hasAIFix: codeActionSet.hasAIFix, allAIFixes: codeActionSet.allAIFixes, dispose: () => { codeActionSet.dispose(); } };
return { validActions: filteredActions, allActions: allCodeActions, documentation: codeActionSet.documentation, hasAutoFix: codeActionSet.hasAutoFix, hasAIFix: codeActionSet.hasAIFix, allAIFixes: codeActionSet.allAIFixes, dispose: () => { this.codeActionsDisposable.value = codeActionSet; } };
}
}
}
Expand Down

0 comments on commit db5460c

Please sign in to comment.