mirror of https://github.com/astral-sh/ruff
[ty] Always register rename provider if client doesn't support dynamic registration (#21789)
This commit is contained in:
parent
3aefe85b32
commit
326025d45f
|
|
@ -1,5 +1,5 @@
|
|||
use lsp_types::{
|
||||
ClientCapabilities, CodeActionKind, CodeActionOptions, CompletionOptions,
|
||||
self as types, ClientCapabilities, CodeActionKind, CodeActionOptions, CompletionOptions,
|
||||
DeclarationCapability, DiagnosticOptions, DiagnosticServerCapabilities,
|
||||
HoverProviderCapability, InlayHintOptions, InlayHintServerCapabilities, MarkupKind,
|
||||
NotebookCellSelector, NotebookSelector, OneOf, RenameOptions, SelectionRangeProviderCapability,
|
||||
|
|
@ -8,11 +8,9 @@ use lsp_types::{
|
|||
TextDocumentSyncCapability, TextDocumentSyncKind, TextDocumentSyncOptions,
|
||||
TypeDefinitionProviderCapability, WorkDoneProgressOptions,
|
||||
};
|
||||
use std::str::FromStr;
|
||||
|
||||
use crate::PositionEncoding;
|
||||
use crate::session::GlobalSettings;
|
||||
use lsp_types as types;
|
||||
use std::str::FromStr;
|
||||
|
||||
bitflags::bitflags! {
|
||||
/// Represents the resolved client capabilities for the language server.
|
||||
|
|
@ -349,7 +347,6 @@ impl ResolvedClientCapabilities {
|
|||
pub(crate) fn server_capabilities(
|
||||
position_encoding: PositionEncoding,
|
||||
resolved_client_capabilities: ResolvedClientCapabilities,
|
||||
global_settings: &GlobalSettings,
|
||||
) -> ServerCapabilities {
|
||||
let diagnostic_provider =
|
||||
if resolved_client_capabilities.supports_diagnostic_dynamic_registration() {
|
||||
|
|
@ -368,11 +365,9 @@ pub(crate) fn server_capabilities(
|
|||
// dynamically based on the `ty.experimental.rename` setting.
|
||||
None
|
||||
} else {
|
||||
// Otherwise, we check whether user has enabled rename support via the resolved settings
|
||||
// from initialization options.
|
||||
global_settings
|
||||
.is_rename_enabled()
|
||||
.then(|| OneOf::Right(server_rename_options()))
|
||||
// Otherwise, we always register the rename provider and bail out in `prepareRename` if
|
||||
// the feature is disabled.
|
||||
Some(OneOf::Right(server_rename_options()))
|
||||
};
|
||||
|
||||
ServerCapabilities {
|
||||
|
|
|
|||
|
|
@ -72,15 +72,8 @@ impl Server {
|
|||
tracing::debug!("Resolved client capabilities: {resolved_client_capabilities}");
|
||||
|
||||
let position_encoding = Self::find_best_position_encoding(&client_capabilities);
|
||||
let server_capabilities = server_capabilities(
|
||||
position_encoding,
|
||||
resolved_client_capabilities,
|
||||
&initialization_options
|
||||
.options
|
||||
.global
|
||||
.clone()
|
||||
.into_settings(),
|
||||
);
|
||||
let server_capabilities =
|
||||
server_capabilities(position_encoding, resolved_client_capabilities);
|
||||
|
||||
let version = ruff_db::program_version().unwrap_or("Unknown");
|
||||
tracing::info!("Version: {version}");
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ impl BackgroundDocumentRequestHandler for PrepareRenameRequestHandler {
|
|||
if snapshot
|
||||
.workspace_settings()
|
||||
.is_language_services_disabled()
|
||||
|| !snapshot.global_settings().is_rename_enabled()
|
||||
{
|
||||
return Ok(None);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -564,7 +564,7 @@ impl Session {
|
|||
publish_settings_diagnostics(self, client, root);
|
||||
}
|
||||
|
||||
if let Some(global_options) = combined_global_options.take() {
|
||||
if let Some(global_options) = combined_global_options {
|
||||
let global_settings = global_options.into_settings();
|
||||
if global_settings.diagnostic_mode().is_workspace() {
|
||||
for project in self.projects.values_mut() {
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ expression: initialization_result
|
|||
"quickfix"
|
||||
]
|
||||
},
|
||||
"renameProvider": {
|
||||
"prepareProvider": true
|
||||
},
|
||||
"declarationProvider": true,
|
||||
"executeCommandProvider": {
|
||||
"commands": [
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ expression: initialization_result
|
|||
"quickfix"
|
||||
]
|
||||
},
|
||||
"renameProvider": {
|
||||
"prepareProvider": true
|
||||
},
|
||||
"declarationProvider": true,
|
||||
"executeCommandProvider": {
|
||||
"commands": [
|
||||
|
|
|
|||
Loading…
Reference in New Issue