fix: avoid duplicated method completion (#349)

This commit is contained in:
Myriad-Dreamin 2024-06-27 16:00:08 +08:00 committed by GitHub
parent a3724bc87f
commit 0a1c625397
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,9 +5,7 @@ use std::ops::Range;
use ecow::{eco_format, EcoString};
use if_chain::if_chain;
use serde::{Deserialize, Serialize};
use typst::foundations::{
fields_on, format_str, mutable_methods_on, repr, Repr, StyleChain, Styles, Value,
};
use typst::foundations::{fields_on, format_str, repr, Repr, StyleChain, Styles, Value};
use typst::model::Document;
use typst::syntax::ast::AstNode;
use typst::syntax::{ast, is_id_continue, is_id_start, is_ident, LinkedNode, Source, SyntaxKind};
@ -402,19 +400,6 @@ fn field_access_completions(ctx: &mut CompletionContext, value: &Value, styles:
}
}
for &(method, args) in mutable_methods_on(value.ty()) {
ctx.completions.push(Completion {
kind: CompletionKind::Func,
label: method.into(),
apply: Some(if args {
eco_format!("{method}(${{}})")
} else {
eco_format!("{method}()${{}}")
}),
..Completion::default()
})
}
for &field in fields_on(value.ty()) {
// Complete the field name along with its value. Notes:
// 1. No parentheses since function fields cannot currently be called