mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Remove possible multiline details in completions
This commit is contained in:
parent
3e4ac8a2c9
commit
0c98a01b3e
10 changed files with 81 additions and 63 deletions
|
@ -4,6 +4,7 @@ use either::Either;
|
|||
use hir::{AsAssocItem, HasSource, HirDisplay};
|
||||
use ide_db::SymbolKind;
|
||||
use itertools::Itertools;
|
||||
use stdx::format_to;
|
||||
use syntax::ast;
|
||||
|
||||
use crate::{
|
||||
|
@ -122,14 +123,11 @@ impl<'a> FunctionRender<'a> {
|
|||
|
||||
fn detail(&self) -> String {
|
||||
let ret_ty = self.func.ret_type(self.ctx.db());
|
||||
let ret = if ret_ty.is_unit() {
|
||||
// Omit the return type if it is the unit type
|
||||
String::new()
|
||||
} else {
|
||||
format!(" {}", self.ty_display())
|
||||
};
|
||||
|
||||
format!("fn({}){}", self.params_display(), ret)
|
||||
let mut detail = format!("fn({})", self.params_display());
|
||||
if !ret_ty.is_unit() {
|
||||
format_to!(detail, " -> {}", ret_ty.display(self.ctx.db()));
|
||||
}
|
||||
detail
|
||||
}
|
||||
|
||||
fn params_display(&self) -> String {
|
||||
|
@ -153,12 +151,6 @@ impl<'a> FunctionRender<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn ty_display(&self) -> String {
|
||||
let ret_ty = self.func.ret_type(self.ctx.db());
|
||||
|
||||
format!("-> {}", ret_ty.display(self.ctx.db()))
|
||||
}
|
||||
|
||||
fn params(&self) -> Params {
|
||||
let ast_params = match self.ast_node.param_list() {
|
||||
Some(it) => it,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue