Declare appearance function in KCL (#7220)
Move appearance to KCL Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
@ -463,7 +463,11 @@ impl ModData {
|
||||
}
|
||||
|
||||
pub fn find_by_name(&self, name: &str) -> Option<&DocData> {
|
||||
if let Some(result) = self.children.values().find(|dd| dd.name() == name) {
|
||||
if let Some(result) = self
|
||||
.children
|
||||
.values()
|
||||
.find(|dd| dd.name() == name && !matches!(dd, DocData::Mod(_)))
|
||||
{
|
||||
return Some(result);
|
||||
}
|
||||
|
||||
@ -824,7 +828,13 @@ impl ArgData {
|
||||
Some("[Edge; 1+]") => Some((index, format!(r#"{label}[${{{index}:tag_or_edge_fn}}]"#))),
|
||||
Some("Plane") => Some((index, format!(r#"{label}${{{}:XY}}"#, index))),
|
||||
|
||||
Some("string") => Some((index, format!(r#"{label}${{{}:"string"}}"#, index))),
|
||||
Some("string") => {
|
||||
if self.name == "color" {
|
||||
Some((index, format!(r#"{label}${{{}:"ff0000"}}"#, index)))
|
||||
} else {
|
||||
Some((index, format!(r#"{label}${{{}:"string"}}"#, index)))
|
||||
}
|
||||
}
|
||||
Some("bool") => Some((index, format!(r#"{label}${{{}:false}}"#, index))),
|
||||
_ => None,
|
||||
}
|
||||
|
@ -1074,12 +1074,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn get_autocomplete_snippet_appearance() {
|
||||
let appearance_fn: Box<dyn StdLibFn> = Box::new(crate::std::appearance::Appearance);
|
||||
let snippet = appearance_fn.to_autocomplete_snippet().unwrap();
|
||||
assert_eq!(
|
||||
snippet,
|
||||
r#"appearance(${0:%}, color = ${1:"#.to_owned() + "\"#" + r#"ff0000"})"#
|
||||
);
|
||||
let data = kcl_doc::walk_prelude();
|
||||
let DocData::Fn(helix_fn) = data.find_by_name("appearance").unwrap() else {
|
||||
panic!();
|
||||
};
|
||||
let snippet = helix_fn.to_autocomplete_snippet();
|
||||
assert_eq!(snippet, r#"appearance(color = ${0:"ff0000"})"#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Reference in New Issue
Block a user