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(language_server): do not tell clients about codeActionProvider when they do not support codeActionLiteralSupport #7445

Merged
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
28 changes: 19 additions & 9 deletions crates/oxc_language_server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,24 @@ impl LanguageServer for Backend {
info!("language server version: {:?}", env!("CARGO_PKG_VERSION"));
*self.options.lock().await = value;
}

// check if the client support some code action literal support
let code_action_provider = if params.capabilities.text_document.is_some_and(|capability| {
capability.code_action.is_some_and(|code_action| {
code_action.code_action_literal_support.is_some_and(|literal_support| {
!literal_support.code_action_kind.value_set.is_empty()
})
})
}) {
Some(CodeActionProviderCapability::Options(CodeActionOptions {
code_action_kinds: Some(vec![CodeActionKind::QUICKFIX]),
work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None },
resolve_provider: None,
}))
} else {
None
};

self.init_linter_config().await;
Ok(InitializeResult {
server_info: Some(ServerInfo { name: "oxc".into(), version: None }),
Expand All @@ -114,15 +132,7 @@ impl LanguageServer for Backend {
}),
file_operations: None,
}),
code_action_provider: Some(CodeActionProviderCapability::Options(
CodeActionOptions {
code_action_kinds: Some(vec![CodeActionKind::QUICKFIX]),
work_done_progress_options: WorkDoneProgressOptions {
work_done_progress: None,
},
resolve_provider: None,
},
)),
code_action_provider,
..ServerCapabilities::default()
},
})
Expand Down
Loading