fix(converter): YAML => KDL conversion with backslash hotkey. (#1879)

* Fixing YAML => KDL conversion with backslash hotkey.

Previously if the hotkey of backslash was used the yaml => kdl
conversion would create a KDL statement like so: `bind "\" {...}`.
That is incorrect kdl syntax since the backslash escapes the following
quote character. A way to get proper KDL is `bind r"\" {...}`. This
commit changes if the old HotKey is a backslash a properly creates KDL
syntax to address the backslash character.

* rustfmt
This commit is contained in:
noyez 2022-11-02 11:39:56 -04:00 committed by GitHub
parent 4ab04c59a2
commit c8f3b94fde
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -424,7 +424,13 @@ fn keybinds_yaml_to_keybinds_kdl(keybinds_yaml: &OldKeybindsFromYaml) -> String
let actions = &key_action.action;
let key_string: String = keys
.iter()
.map(|k| format!("\"{}\"", k))
.map(|k| {
if k == &OldKey::Char('\\') {
format!("r\"{}\"", k)
} else {
format!("\"{}\"", k)
}
})
.collect::<Vec<String>>()
.join(" ");
let actions_string: String = actions