Skip to content

Commit 0f8d903

Browse files
authored
fix: no code actions for Nearby Quick Fixes (#197691)
* double checks if provider provides code actions * better check for if we need to add new actions
1 parent fff2eae commit 0f8d903

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/vs/editor/contrib/codeAction/browser/codeActionModel.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export class CodeActionModel extends Disposable {
210210
const actions = createCancelablePromise(async token => {
211211
if (this._settingEnabledNearbyQuickfixes() && trigger.trigger.type === CodeActionTriggerType.Invoke && (trigger.trigger.triggerAction === CodeActionTriggerSource.QuickFix || trigger.trigger.filter?.include?.contains(CodeActionKind.QuickFix))) {
212212
const codeActionSet = await getCodeActions(this._registry, model, trigger.selection, trigger.trigger, Progress.None, token);
213-
213+
const allCodeActions = [...codeActionSet.allActions];
214214
if (token.isCancellationRequested) {
215215
return emptyCodeActionSet;
216216
}
@@ -251,6 +251,11 @@ export class CodeActionModel extends Disposable {
251251
for (const action of actionsAtMarker.validActions) {
252252
action.highlightRange = action.action.isPreferred;
253253
}
254+
255+
if (codeActionSet.allActions.length === 0) {
256+
allCodeActions.push(...actionsAtMarker.allActions);
257+
}
258+
254259
// Already filtered through to only get quickfixes, so no need to filter again.
255260
if (Math.abs(currPosition.column - col) < distance) {
256261
currentActions.unshift(...actionsAtMarker.validActions);
@@ -279,7 +284,7 @@ export class CodeActionModel extends Disposable {
279284
});
280285

281286
// Only retriggers if actually found quickfix on the same line as cursor
282-
return { validActions: filteredActions, allActions: codeActionSet.allActions, documentation: codeActionSet.documentation, hasAutoFix: codeActionSet.hasAutoFix, dispose: () => { codeActionSet.dispose(); } };
287+
return { validActions: filteredActions, allActions: allCodeActions, documentation: codeActionSet.documentation, hasAutoFix: codeActionSet.hasAutoFix, dispose: () => { codeActionSet.dispose(); } };
283288
}
284289
}
285290
}

0 commit comments

Comments
 (0)