ruff/crates/ty_server/src
Andrew Gallant 196a68e4c8 [ty] Render `import <...>` in completions when "label details" isn't supported
This fixes a bug where the `import module` part of a completion for
unimported candidates would be missing. This makes it especially
confusing because the user can't tell where the symbol is coming from,
and there is no hint that an `import` statement will be inserted.

Previously, we were using [`CompletionItemLabelDetails`] to render the
`import module` part of the suggestion. But this is only supported in
clients that support version 3.17 (or newer) of the LSP specification.
It turns out that this support isn't widespread yet. In particular,
Heliex doesn't seem to support "label details."

To fix this, we take a [cue from rust-analyzer][rust-analyzer-details].
We detect if the client supports "label details," and if so, use it.
Otherwise, we push the `import module` text into the completion label
itself.

Fixes https://github.com/astral-sh/ruff/pull/20439#issuecomment-3313689568

[`CompletionItemLabelDetails`]: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionItemLabelDetails
[rust-analyzer-details]: 5d905576d4/crates/rust-analyzer/src/lsp/to_proto.rs (L391-L404)
2025-10-29 08:50:41 -04:00
..
document [ty] Added support for "document highlights" language server feature. (#19515) 2025-07-24 13:06:25 -07:00
server [ty] Render `import <...>` in completions when "label details" isn't supported 2025-10-29 08:50:41 -04:00
session Update Rust crate anyhow to v1.0.100 (#20499) 2025-09-22 09:51:52 +02:00
capabilities.rs [ty] Render `import <...>` in completions when "label details" isn't supported 2025-10-29 08:50:41 -04:00
document.rs [ty] Fix stale documents on Windows (#18544) 2025-06-09 16:39:11 +02:00
lib.rs [ty] Support LSP client settings (#19614) 2025-08-06 18:37:21 +05:30
logging.rs [ty] Speedup tracing checks (#19965) 2025-08-18 12:56:06 +02:00
server.rs [ty] Log server version at info level (#19961) 2025-08-18 07:16:53 +00:00
session.rs Allow the `if_not_else` Clippy lint 2025-09-09 08:49:25 -04:00
system.rs [ty] Support goto-definition on vendored typeshed stubs (#21020) 2025-10-21 13:38:40 -04:00