refactor complete_fn_fields function and correct branch checks

This commit is contained in:
dfireBird 2023-11-22 18:33:38 +05:30
parent 8296b16f38
commit 5c0c8ceaf7
No known key found for this signature in database
GPG key ID: 26D522CA5FC2B93D
2 changed files with 22 additions and 45 deletions

View file

@ -148,7 +148,9 @@ pub(crate) fn render_field(
.set_documentation(field.docs(db))
.set_deprecated(is_deprecated)
.lookup_by(name);
if ty.is_fn() || ty.is_closure() {
let is_field_access = matches!(dot_access.kind, DotAccessKind::Field { .. });
if !is_field_access || ty.is_fn() || ty.is_closure() {
let mut builder = TextEdit::builder();
// Using TextEdit, insert '(' before the struct name and ')' before the
// dot access, then comes the field name and optionally insert function