summaryrefslogtreecommitdiff
path: root/crates/typst-ide/src
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2024-07-15 20:01:51 +0200
committerGitHub <noreply@github.com>2024-07-15 18:01:51 +0000
commit09e0464e875fccecd6f2f686d462ad2c4a3b5ecd (patch)
treefa24b8cc84830942ab18dadd3bdedfe1a4d7ae84 /crates/typst-ide/src
parentf3863f14aff07ec2d0260e0edf9fe3f4f7205d8e (diff)
Fix duplicate completions (#4563)
Diffstat (limited to 'crates/typst-ide/src')
-rw-r--r--crates/typst-ide/src/complete.rs27
1 files changed, 10 insertions, 17 deletions
diff --git a/crates/typst-ide/src/complete.rs b/crates/typst-ide/src/complete.rs
index f6c96d00..d534f55c 100644
--- a/crates/typst-ide/src/complete.rs
+++ b/crates/typst-ide/src/complete.rs
@@ -5,8 +5,8 @@ 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, AutoValue, CastInfo, Func, Label,
- NoneValue, Repr, Scope, StyleChain, Styles, Type, Value,
+ fields_on, format_str, repr, AutoValue, CastInfo, Func, Label, NoneValue, Repr,
+ Scope, StyleChain, Styles, Type, Value,
};
use typst::model::Document;
use typst::syntax::{
@@ -396,19 +396,6 @@ fn field_access_completions(
}
}
- 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}()${{}}")
- }),
- detail: None,
- })
- }
-
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
@@ -1394,7 +1381,7 @@ mod tests {
}
#[test]
- fn test_whitespace_in_autocomplete() {
+ fn test_autocomplete_whitespace() {
//Check that extra space before '.' is handled correctly.
test("#() .", 5, &[], &["insert", "remove", "len", "all"]);
test("#{() .}", 6, &["insert", "remove", "len", "all"], &["foo"]);
@@ -1404,10 +1391,16 @@ mod tests {
}
#[test]
- fn test_before_window_char_boundary() {
+ fn test_autocomplete_before_window_char_boundary() {
// Check that the `before_window` doesn't slice into invalid byte
// boundaries.
let s = "😀😀 #text(font: \"\")";
test(s, s.len() - 2, &[], &[]);
}
+
+ #[test]
+ fn test_autocomplete_mutable_method() {
+ let s = "#{ let x = (1, 2, 3); x. }";
+ test(s, s.len() - 2, &["at", "push", "pop"], &[]);
+ }
}