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
1b5389da57
commit
cc4d1190ae
|
|
@ -81,8 +81,10 @@ impl BackgroundDocumentRequestHandler for CompletionRequestHandler {
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
let name = comp.name.to_string();
|
let name = comp.insert.as_deref().unwrap_or(&comp.name).to_string();
|
||||||
let import_suffix = comp.module_name.map(|name| format!(" (import {name})"));
|
let import_suffix = comp
|
||||||
|
.module_name
|
||||||
|
.and_then(|name| import_edit.is_some().then(|| format!(" (import {name})")));
|
||||||
let (label, label_details) = if snapshot
|
let (label, label_details) = if snapshot
|
||||||
.resolved_client_capabilities()
|
.resolved_client_capabilities()
|
||||||
.supports_completion_item_label_details()
|
.supports_completion_item_label_details()
|
||||||
|
|
|
||||||
|
|
@ -110,13 +110,13 @@ TypedDi<CURSOR>
|
||||||
insta::assert_json_snapshot!(completions, @r#"
|
insta::assert_json_snapshot!(completions, @r#"
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"label": "TypedDict (import typing)",
|
"label": "typing.TypedDict",
|
||||||
"kind": 6,
|
"kind": 6,
|
||||||
"sortText": "0",
|
"sortText": "0",
|
||||||
"insertText": "typing.TypedDict"
|
"insertText": "typing.TypedDict"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "is_typeddict (import typing)",
|
"label": "typing.is_typeddict",
|
||||||
"kind": 3,
|
"kind": 3,
|
||||||
"sortText": "1",
|
"sortText": "1",
|
||||||
"insertText": "typing.is_typeddict"
|
"insertText": "typing.is_typeddict"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue