mirror of https://github.com/astral-sh/ruff
[ty] Swap `detail` and `description` fields for `CompletionItemLabelDetails`
This seems to be more consistent with how other LSPs work (like `rust-analyzer`), and also I think is more consistent with how `CompletionItem.detail` is itself rendered. Namely, in VS Code, it is right-aligned. And it's also where we put the type signature. But `CompletionItemLabelDetails.detail` is left-aligned where as `CompletionItemLabelDetails.description` is right-aligned. So let's swap them such that type signatures go in the latter and not the former. This also adds a space before the module name and contextualizes it with `(import <name>)` to help aide the end user in figuring out selecting the completion will do. Fixes #1200
This commit is contained in:
parent
48ada2d359
commit
1ebbe73a1d
|
|
@ -87,8 +87,8 @@ impl BackgroundDocumentRequestHandler for CompletionRequestHandler {
|
|||
sort_text: Some(format!("{i:-max_index_len$}")),
|
||||
detail: type_display.clone(),
|
||||
label_details: Some(CompletionItemLabelDetails {
|
||||
detail: type_display,
|
||||
description: comp.module_name.map(ToString::to_string),
|
||||
detail: comp.module_name.map(|name| format!(" (import {name})")),
|
||||
description: type_display,
|
||||
}),
|
||||
insert_text: comp.insert.map(String::from),
|
||||
additional_text_edits: import_edit.map(|edit| vec![edit]),
|
||||
|
|
|
|||
Loading…
Reference in New Issue