mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
fix close parens position to move after field access
This commit is contained in:
parent
21c09eb544
commit
b7effe54ee
2 changed files with 5 additions and 14 deletions
|
@ -37,9 +37,6 @@ pub(crate) fn complete_dot(
|
|||
is_field_access,
|
||||
);
|
||||
|
||||
if let DotAccessKind::Method { .. } = dot_access.kind {
|
||||
cov_mark::hit!(test_no_struct_field_completion_for_method_call);
|
||||
}
|
||||
complete_methods(ctx, receiver_ty, |func| acc.add_method(ctx, dot_access, func, None, None));
|
||||
}
|
||||
|
||||
|
@ -259,7 +256,6 @@ impl A {
|
|||
|
||||
#[test]
|
||||
fn test_no_struct_field_completion_for_method_call() {
|
||||
cov_mark::check!(test_no_struct_field_completion_for_method_call);
|
||||
check(
|
||||
r#"
|
||||
struct A { the_field: u32 }
|
||||
|
@ -1202,7 +1198,7 @@ fn foo() { S { va_field: 0, fn_field: || {} }.fi$0() }
|
|||
"#,
|
||||
r#"
|
||||
struct S { va_field: u32, fn_field: fn() }
|
||||
fn foo() { (S { va_field: 0, fn_field: || {} }).fn_field() }
|
||||
fn foo() { (S { va_field: 0, fn_field: || {} }.fn_field)() }
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
@ -1235,7 +1231,7 @@ fn foo() {
|
|||
struct B(u32, fn())
|
||||
fn foo() {
|
||||
let b = B(0, || {});
|
||||
(b).1()
|
||||
(b.1)()
|
||||
}
|
||||
"#,
|
||||
)
|
||||
|
|
|
@ -167,9 +167,8 @@ pub(crate) fn render_field(
|
|||
if !expected_fn_type {
|
||||
if let Some(receiver) = &dot_access.receiver {
|
||||
if let Some(receiver) = ctx.completion.sema.original_ast_node(receiver.clone()) {
|
||||
let range = receiver.syntax().text_range();
|
||||
builder.insert(range.start(), "(".to_string());
|
||||
builder.insert(range.end(), ")".to_string());
|
||||
builder.insert(receiver.syntax().text_range().start(), "(".to_string());
|
||||
builder.insert(ctx.source_range().end(), ")".to_string());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1676,11 +1675,7 @@ fn foo(f: Foo) { let _: &u32 = f.b$0 }
|
|||
delete: 107..107,
|
||||
},
|
||||
Indel {
|
||||
insert: ")",
|
||||
delete: 108..108,
|
||||
},
|
||||
Indel {
|
||||
insert: "qux()",
|
||||
insert: "qux)()",
|
||||
delete: 109..110,
|
||||
},
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue