Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
12 changes: 7 additions & 5 deletions pyrefly/lib/lsp/non_wasm/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ pub fn capabilities(
CodeActionKind::new("refactor.delete"),
CodeActionKind::new("refactor.move"),
CodeActionKind::REFACTOR_INLINE,
CodeActionKind::SOURCE_FIX_ALL,
CodeActionKind::new(SOURCE_FIX_ALL_PYREFLY),
]),
..Default::default()
})),
Expand Down Expand Up @@ -1252,6 +1252,7 @@ pub enum ProcessEvent {
}

const PYTHON_SECTION: &str = "python";
const SOURCE_FIX_ALL_PYREFLY: &str = "source.fixAll.pyrefly";

struct TypeHierarchyTarget {
def_index: ClassDefIndex,
Expand Down Expand Up @@ -4171,9 +4172,10 @@ impl Server {
let allow_quickfix = only_kinds
.is_none_or(|kinds| kinds.iter().any(|kind| kind == &CodeActionKind::QUICKFIX));
let allow_fix_all = only_kinds.is_none_or(|kinds| {
kinds
.iter()
.any(|kind| kind == &CodeActionKind::SOURCE_FIX_ALL)
kinds.iter().any(|kind| {
kind == &CodeActionKind::SOURCE_FIX_ALL
|| kind.as_str().starts_with(SOURCE_FIX_ALL_PYREFLY)
Copy link
Copy Markdown

@rchl rchl Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the second condition should also match source.fixAll.pyrefly exactly rather than using starts_with because source.fixAll.pyreflyyyyyy shouldn't match, nor should source.fixAll.pyrefly.foo

})
});
let allow_refactor = only_kinds.is_none_or(|kinds| {
kinds
Expand Down Expand Up @@ -4276,7 +4278,7 @@ impl Server {
if !changes.is_empty() {
actions.push(CodeActionOrCommand::CodeAction(CodeAction {
title: "Remove all redundant casts".to_owned(),
kind: Some(CodeActionKind::SOURCE_FIX_ALL),
kind: Some(CodeActionKind::new(SOURCE_FIX_ALL_PYREFLY)),
edit: Some(WorkspaceEdit {
changes: Some(changes),
..Default::default()
Expand Down
2 changes: 1 addition & 1 deletion pyrefly/lib/test/lsp/lsp_interaction/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn test_initialize_basic() {
"definitionProvider": true,
"typeDefinitionProvider": true,
"codeActionProvider": {
"codeActionKinds": ["quickfix", "refactor.extract", "refactor.rewrite", "refactor.delete", "refactor.move", "refactor.inline", "source.fixAll"]
"codeActionKinds": ["quickfix", "refactor.extract", "refactor.rewrite", "refactor.delete", "refactor.move", "refactor.inline", "source.fixAll.pyrefly"]
},
"codeLensProvider": {
"resolveProvider": false,
Expand Down
Loading