mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 22:01:18 +00:00
[ty] Short-circuit inlayhints request if disabled in settings (#19963)
This commit is contained in:
parent
4ac2b2c222
commit
67529edad6
2 changed files with 11 additions and 4 deletions
|
@ -85,6 +85,13 @@ pub struct InlayHintSettings {
|
|||
/// foo("x="1)
|
||||
/// ```
|
||||
pub call_argument_names: bool,
|
||||
// Add any new setting that enables additional inlays to `any_enabled`.
|
||||
}
|
||||
|
||||
impl InlayHintSettings {
|
||||
pub fn any_enabled(&self) -> bool {
|
||||
self.variable_types || self.call_argument_names
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for InlayHintSettings {
|
||||
|
|
|
@ -29,9 +29,9 @@ impl BackgroundDocumentRequestHandler for InlayHintRequestHandler {
|
|||
_client: &Client,
|
||||
params: InlayHintParams,
|
||||
) -> crate::server::Result<Option<Vec<lsp_types::InlayHint>>> {
|
||||
if snapshot
|
||||
.workspace_settings()
|
||||
.is_language_services_disabled()
|
||||
let workspace_settings = snapshot.workspace_settings();
|
||||
if workspace_settings.is_language_services_disabled()
|
||||
|| !workspace_settings.inlay_hints().any_enabled()
|
||||
{
|
||||
return Ok(None);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ impl BackgroundDocumentRequestHandler for InlayHintRequestHandler {
|
|||
.range
|
||||
.to_text_range(&source, &index, snapshot.encoding());
|
||||
|
||||
let inlay_hints = inlay_hints(db, file, range, snapshot.workspace_settings().inlay_hints());
|
||||
let inlay_hints = inlay_hints(db, file, range, workspace_settings.inlay_hints());
|
||||
|
||||
let inlay_hints = inlay_hints
|
||||
.into_iter()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue