fix: ADD_SWITCHER keyword syntax - special handling for 'as' keyword format
The ADD_SWITCHER keyword was generating comma-separated params (ADD_SWITCHER(id, label)) instead of the expected Rhai custom syntax (ADD_SWITCHER id as label). This fix adds special handling in the multiword processor to output the correct format when processing ADD_SWITCHER with 2 parameters. Fixes #495
This commit is contained in:
parent
3048832a2d
commit
9f7da0a291
1 changed files with 17 additions and 11 deletions
|
|
@ -1388,13 +1388,19 @@ pub fn convert_keywords_to_lowercase(script: &str) -> String {
|
||||||
let keyword = pattern.replace(r"\s+", "_");
|
let keyword = pattern.replace(r"\s+", "_");
|
||||||
|
|
||||||
// Build function call
|
// Build function call
|
||||||
|
// Special handling for ADD_SWITCHER which uses "as" syntax
|
||||||
|
let output = if keyword == "ADD_SWITCHER" && params.len() == 2 {
|
||||||
|
format!("ADD_SWITCHER {} as {};", params[0], params[1])
|
||||||
|
} else {
|
||||||
let params_str = if params.is_empty() {
|
let params_str = if params.is_empty() {
|
||||||
String::new()
|
String::new()
|
||||||
} else {
|
} else {
|
||||||
params.join(", ")
|
params.join(", ")
|
||||||
};
|
};
|
||||||
|
format!("{}({});", keyword, params_str)
|
||||||
|
};
|
||||||
|
|
||||||
result.push_str(&format!("{}({});", keyword, params_str));
|
result.push_str(&output);
|
||||||
result.push('\n');
|
result.push('\n');
|
||||||
converted = true;
|
converted = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue