summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-07-06 16:09:37 +0200
committerLaurenz <laurmaedje@gmail.com>2023-07-06 16:09:37 +0200
commit1bb024ca3f75cf9cbad1ef3ff321d3c298dce609 (patch)
treeec12ba0627d8e8446e3c28b32c0adbd631ef74f4 /crates
parentdb09a5a71252771f8539992b53a1d2a8f3149019 (diff)
Fix autocompletion for dictionary key with spaces
Diffstat (limited to 'crates')
-rw-r--r--crates/typst/src/ide/complete.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/crates/typst/src/ide/complete.rs b/crates/typst/src/ide/complete.rs
index 16cba1bc..2c9c386e 100644
--- a/crates/typst/src/ide/complete.rs
+++ b/crates/typst/src/ide/complete.rs
@@ -1042,14 +1042,8 @@ impl<'a> CompletionContext<'a> {
parens: bool,
docs: Option<&str>,
) {
+ let at = label.as_deref().map_or(false, |field| !is_ident(field));
let label = label.unwrap_or_else(|| value.repr().into());
- let mut apply = None;
-
- if label.starts_with('"') && self.after.starts_with('"') {
- if let Some(trimmed) = label.strip_suffix('"') {
- apply = Some(trimmed.into());
- }
- }
let detail = docs.map(Into::into).or_else(|| match value {
Value::Symbol(_) => None,
@@ -1060,8 +1054,15 @@ impl<'a> CompletionContext<'a> {
}
});
+ let mut apply = None;
if parens && matches!(value, Value::Func(_)) {
apply = Some(eco_format!("{label}(${{}})"));
+ } else if at {
+ apply = Some(eco_format!("at(\"{label}\")"));
+ } else if label.starts_with('"') && self.after.starts_with('"') {
+ if let Some(trimmed) = label.strip_suffix('"') {
+ apply = Some(trimmed.into());
+ }
}
self.completions.push(Completion {