Skip to content

Commit 67529ed

Browse files
authored
[ty] Short-circuit inlayhints request if disabled in settings (#19963)
1 parent 4ac2b2c commit 67529ed

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

crates/ty_ide/src/inlay_hints.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ pub struct InlayHintSettings {
8585
/// foo("x="1)
8686
/// ```
8787
pub call_argument_names: bool,
88+
// Add any new setting that enables additional inlays to `any_enabled`.
89+
}
90+
91+
impl InlayHintSettings {
92+
pub fn any_enabled(&self) -> bool {
93+
self.variable_types || self.call_argument_names
94+
}
8895
}
8996

9097
impl Default for InlayHintSettings {

crates/ty_server/src/server/api/requests/inlay_hints.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ impl BackgroundDocumentRequestHandler for InlayHintRequestHandler {
2929
_client: &Client,
3030
params: InlayHintParams,
3131
) -> crate::server::Result<Option<Vec<lsp_types::InlayHint>>> {
32-
if snapshot
33-
.workspace_settings()
34-
.is_language_services_disabled()
32+
let workspace_settings = snapshot.workspace_settings();
33+
if workspace_settings.is_language_services_disabled()
34+
|| !workspace_settings.inlay_hints().any_enabled()
3535
{
3636
return Ok(None);
3737
}
@@ -47,7 +47,7 @@ impl BackgroundDocumentRequestHandler for InlayHintRequestHandler {
4747
.range
4848
.to_text_range(&source, &index, snapshot.encoding());
4949

50-
let inlay_hints = inlay_hints(db, file, range, snapshot.workspace_settings().inlay_hints());
50+
let inlay_hints = inlay_hints(db, file, range, workspace_settings.inlay_hints());
5151

5252
let inlay_hints = inlay_hints
5353
.into_iter()

0 commit comments

Comments
 (0)