mirror of
https://github.com/typst/typst
synced 2025-05-14 17:15:28 +08:00
Fix autocompletion for dictionary key with spaces
This commit is contained in:
parent
db09a5a712
commit
1bb024ca3f
@ -1042,14 +1042,8 @@ impl<'a> CompletionContext<'a> {
|
|||||||
parens: bool,
|
parens: bool,
|
||||||
docs: Option<&str>,
|
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 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 {
|
let detail = docs.map(Into::into).or_else(|| match value {
|
||||||
Value::Symbol(_) => None,
|
Value::Symbol(_) => None,
|
||||||
@ -1060,8 +1054,15 @@ impl<'a> CompletionContext<'a> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let mut apply = None;
|
||||||
if parens && matches!(value, Value::Func(_)) {
|
if parens && matches!(value, Value::Func(_)) {
|
||||||
apply = Some(eco_format!("{label}(${{}})"));
|
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 {
|
self.completions.push(Completion {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user