Skip to content

Commit

Permalink
fix: Irrelevant Quick Fixes after applying code action
Browse files Browse the repository at this point in the history
Fixes redhat-developer#410

Signed-off-by: azerr <[email protected]>
  • Loading branch information
angelozerr committed Jul 6, 2024
1 parent e3f1d6e commit 70d9695
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,21 @@ private void apply(@Nullable CodeAction codeaction,
executeCommand(codeaction.getCommand(), file, editor, languageServerItem);
}
}
clearCodeActionsCache();
}

private static void executeCommand(@NotNull Command command,
private void clearCodeActionsCache() {
if (lazyCodeActions != null) {
lazyCodeActions.clear();
}
}

private void executeCommand(@NotNull Command command,
@NotNull PsiFile file,
@NotNull Editor editor,
@NotNull LanguageServerItem languageServer) {
CommandExecutor.executeCommand(new LSPCommandContext(command, file, LSPCommandContext.ExecutedBy.CODE_ACTION, editor, languageServer));
clearCodeActionsCache();
}

private LanguageServerItem getLanguageServer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ public interface LSPLazyCodeActionProvider {
* @return a code action at the given index and false otherwise.
*/
Either<CodeActionData, Boolean /* false when code action is not already loaded*/> getCodeActionAt(int index);

void clear();
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,9 @@ private static boolean isValidCodeAction(@Nullable Either<org.eclipse.lsp4j.Comm
}
return true;
}

@Override
public void clear() {
super.cancel();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,10 @@ public void cancel() {
lspCodeActionRequest.cancel(true);
}
}

@Override
public void clear() {
cancel();
lspCodeActionRequest = null;
}
}

0 comments on commit 70d9695

Please sign in to comment.