Alight details in comkplation list
This commit is contained in:
parent
c14a3b4a20
commit
943fa46395
7 changed files with 63 additions and 50 deletions
|
|
@ -83,7 +83,7 @@ fn foo(s: S) { s.<|> }
|
|||
"#,
|
||||
expect![[r#"
|
||||
me bar() fn bar(&self)
|
||||
fd foo u32
|
||||
fd foo u32
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ impl S {
|
|||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
me foo() fn foo(self)
|
||||
me foo() fn foo(self)
|
||||
fd the_field (u32,)
|
||||
"#]],
|
||||
)
|
||||
|
|
@ -114,7 +114,7 @@ impl A {
|
|||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
me foo() fn foo(&self)
|
||||
me foo() fn foo(&self)
|
||||
fd the_field (u32, i32)
|
||||
"#]],
|
||||
)
|
||||
|
|
@ -148,7 +148,7 @@ fn foo(a: inner::A) { a.<|> }
|
|||
"#,
|
||||
expect![[r#"
|
||||
fd crate_field u32
|
||||
fd pub_field u32
|
||||
fd pub_field u32
|
||||
fd super_field u32
|
||||
"#]],
|
||||
);
|
||||
|
|
|
|||
|
|
@ -216,17 +216,17 @@ mod tests {
|
|||
check(
|
||||
r"use a::<|>",
|
||||
expect![[r#"
|
||||
kw self
|
||||
kw super::
|
||||
"#]],
|
||||
kw self
|
||||
kw super::
|
||||
"#]],
|
||||
);
|
||||
|
||||
check(
|
||||
r"use a::{b, <|>}",
|
||||
expect![[r#"
|
||||
kw self
|
||||
kw super::
|
||||
"#]],
|
||||
kw self
|
||||
kw super::
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ fn foo() {
|
|||
expect![[r#"
|
||||
st Bar
|
||||
en E
|
||||
ev X ()
|
||||
ev X ()
|
||||
ct Z
|
||||
md m
|
||||
"#]],
|
||||
|
|
|
|||
|
|
@ -260,14 +260,14 @@ fn main() {
|
|||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
sn box Box::new(expr)
|
||||
sn call function(expr)
|
||||
sn dbg dbg!(expr)
|
||||
sn if if expr {}
|
||||
sn box Box::new(expr)
|
||||
sn call function(expr)
|
||||
sn dbg dbg!(expr)
|
||||
sn if if expr {}
|
||||
sn match match expr {}
|
||||
sn not !expr
|
||||
sn ref &expr
|
||||
sn refm &mut expr
|
||||
sn not !expr
|
||||
sn ref &expr
|
||||
sn refm &mut expr
|
||||
sn while while expr {}
|
||||
"#]],
|
||||
);
|
||||
|
|
@ -283,12 +283,12 @@ fn main() {
|
|||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
sn box Box::new(expr)
|
||||
sn call function(expr)
|
||||
sn dbg dbg!(expr)
|
||||
sn box Box::new(expr)
|
||||
sn call function(expr)
|
||||
sn dbg dbg!(expr)
|
||||
sn match match expr {}
|
||||
sn ref &expr
|
||||
sn refm &mut expr
|
||||
sn ref &expr
|
||||
sn refm &mut expr
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ fn foo() { let _ = E::<|> }
|
|||
"#,
|
||||
expect![[r#"
|
||||
ev Bar(…) (i32)
|
||||
ev Foo ()
|
||||
ev Foo ()
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
|
@ -354,8 +354,8 @@ impl S {
|
|||
fn foo() { let _ = S::<|> }
|
||||
"#,
|
||||
expect![[r#"
|
||||
ct C const C: i32 = 42;
|
||||
ta T type T = i32;
|
||||
ct C const C: i32 = 42;
|
||||
ta T type T = i32;
|
||||
fn a() fn a()
|
||||
me b() fn b(&self)
|
||||
"#]],
|
||||
|
|
@ -382,8 +382,8 @@ mod m {
|
|||
fn foo() { let _ = S::<|> }
|
||||
"#,
|
||||
expect![[r#"
|
||||
ct PUBLIC_CONST pub(super) const PUBLIC_CONST: u32 = 1;
|
||||
ta PublicType pub(super) type PublicType = u32;
|
||||
ct PUBLIC_CONST pub(super) const PUBLIC_CONST: u32 = 1;
|
||||
ta PublicType pub(super) type PublicType = u32;
|
||||
fn public_method() pub(super) fn public_method()
|
||||
"#]],
|
||||
);
|
||||
|
|
@ -504,13 +504,13 @@ trait Sub: Super {
|
|||
fn foo<T: Sub>() { T::<|> }
|
||||
"#,
|
||||
expect![[r#"
|
||||
ct C2 const C2: ();
|
||||
ct CONST const CONST: u8;
|
||||
ta SubTy type SubTy;
|
||||
ta Ty type Ty;
|
||||
fn func() fn func()
|
||||
me method() fn method(&self)
|
||||
fn subfunc() fn subfunc()
|
||||
ct C2 const C2: ();
|
||||
ct CONST const CONST: u8;
|
||||
ta SubTy type SubTy;
|
||||
ta Ty type Ty;
|
||||
fn func() fn func()
|
||||
me method() fn method(&self)
|
||||
fn subfunc() fn subfunc()
|
||||
me submethod() fn submethod(&self)
|
||||
"#]],
|
||||
);
|
||||
|
|
@ -544,13 +544,13 @@ impl<T> Sub for Wrap<T> {
|
|||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
ct C2 const C2: () = ();
|
||||
ct CONST const CONST: u8 = 0;
|
||||
ta SubTy type SubTy;
|
||||
ta Ty type Ty;
|
||||
fn func() fn func()
|
||||
me method() fn method(&self)
|
||||
fn subfunc() fn subfunc()
|
||||
ct C2 const C2: () = ();
|
||||
ct CONST const CONST: u8 = 0;
|
||||
ta SubTy type SubTy;
|
||||
ta Ty type Ty;
|
||||
fn func() fn func()
|
||||
me method() fn method(&self)
|
||||
fn subfunc() fn subfunc()
|
||||
me submethod() fn submethod(&self)
|
||||
"#]],
|
||||
);
|
||||
|
|
@ -586,7 +586,7 @@ fn main() { let _ = crate::<|> }
|
|||
expect![[r##"
|
||||
ma foo!(…) #[macro_export]
|
||||
macro_rules! foo
|
||||
fn main() fn main()
|
||||
fn main() fn main()
|
||||
"##]],
|
||||
);
|
||||
}
|
||||
|
|
@ -630,7 +630,7 @@ mod p {
|
|||
expect![[r#"
|
||||
ct RIGHT_CONST
|
||||
st RightType
|
||||
fn right_fn() fn wrong_fn()
|
||||
fn right_fn() fn wrong_fn()
|
||||
"#]],
|
||||
);
|
||||
|
||||
|
|
@ -676,7 +676,7 @@ fn main() { m!(self::f<|>); }
|
|||
fn foo() {}
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn foo() fn foo()
|
||||
fn foo() fn foo()
|
||||
fn main() fn main()
|
||||
"#]],
|
||||
);
|
||||
|
|
|
|||
|
|
@ -84,9 +84,9 @@ mod tests {
|
|||
check(
|
||||
r#"fn foo(x: i32) { <|> }"#,
|
||||
expect![[r#"
|
||||
sn pd
|
||||
sn ppd
|
||||
"#]],
|
||||
sn pd
|
||||
sn ppd
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,12 +43,21 @@ pub(crate) fn completion_list_with_config(
|
|||
.filter(|c| c.completion_kind == kind)
|
||||
.collect();
|
||||
kind_completions.sort_by_key(|c| c.label().to_owned());
|
||||
let label_width = kind_completions
|
||||
.iter()
|
||||
.map(|it| monospace_width(it.label()))
|
||||
.max()
|
||||
.unwrap_or_default()
|
||||
.min(16);
|
||||
kind_completions
|
||||
.into_iter()
|
||||
.map(|it| {
|
||||
let mut buf = format!("{} {}", it.kind().unwrap().tag(), it.label());
|
||||
let tag = it.kind().unwrap().tag();
|
||||
let var_name = format!("{} {}", tag, it.label());
|
||||
let mut buf = var_name;
|
||||
if let Some(detail) = it.detail() {
|
||||
format_to!(buf, " {}", detail);
|
||||
let width = label_width.saturating_sub(monospace_width(it.label()));
|
||||
format_to!(buf, "{:width$} {}", "", detail, width = width);
|
||||
}
|
||||
format_to!(buf, "\n");
|
||||
buf
|
||||
|
|
@ -56,6 +65,10 @@ pub(crate) fn completion_list_with_config(
|
|||
.collect()
|
||||
}
|
||||
|
||||
fn monospace_width(s: &str) -> usize {
|
||||
s.chars().count()
|
||||
}
|
||||
|
||||
pub(crate) fn check_edit(what: &str, ra_fixture_before: &str, ra_fixture_after: &str) {
|
||||
check_edit_with_config(what, ra_fixture_before, ra_fixture_after, &CompletionConfig::default())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue