mirror of https://github.com/astral-sh/ruff
[ty] Tweak how we show qualified auto-import completions
Specifically, we make two changes: 1. We only show `import ...` when there is an actual import edit. 2. We now show the text we will insert. This means that when we insert a qualified symbol, the qualification will show in the completions suggested. Ref https://github.com/astral-sh/ty/issues/1274#issuecomment-3352233790
This commit is contained in:
parent
0589700ca1
commit
cc23af944f
|
|
@ -81,8 +81,10 @@ impl BackgroundDocumentRequestHandler for CompletionRequestHandler {
|
|||
})
|
||||
});
|
||||
|
||||
let name = comp.name.to_string();
|
||||
let import_suffix = comp.module_name.map(|name| format!(" (import {name})"));
|
||||
let name = comp.insert.as_deref().unwrap_or(&comp.name).to_string();
|
||||
let import_suffix = comp
|
||||
.module_name
|
||||
.and_then(|name| import_edit.is_some().then(|| format!(" (import {name})")));
|
||||
let (label, label_details) = if snapshot
|
||||
.resolved_client_capabilities()
|
||||
.supports_completion_item_label_details()
|
||||
|
|
|
|||
|
|
@ -110,13 +110,13 @@ TypedDi<CURSOR>
|
|||
insta::assert_json_snapshot!(completions, @r#"
|
||||
[
|
||||
{
|
||||
"label": "TypedDict (import typing)",
|
||||
"label": "typing.TypedDict",
|
||||
"kind": 6,
|
||||
"sortText": "0",
|
||||
"insertText": "typing.TypedDict"
|
||||
},
|
||||
{
|
||||
"label": "is_typeddict (import typing)",
|
||||
"label": "typing.is_typeddict",
|
||||
"kind": 3,
|
||||
"sortText": "1",
|
||||
"insertText": "typing.is_typeddict"
|
||||
|
|
|
|||
Loading…
Reference in New Issue