mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-03 00:41:56 -06:00
fix(ui): preserve alignment shortcuts for CLI consumers
This commit is contained in:
@@ -64,7 +64,15 @@ pub struct CommandInfo {
|
||||
impl CommandInfo {
|
||||
/// Format the portable shortcut notation for the runtime operating system.
|
||||
pub fn shortcut_for_platform(&self, mac: bool) -> Option<String> {
|
||||
let keys = if mac { self.shortcut_mac.or(self.shortcut) } else { self.shortcut }?;
|
||||
let keys = if mac {
|
||||
self.shortcut_mac.or(self.shortcut)
|
||||
} else if self.shortcut_mac.is_some() && self.shortcut_mac == self.shortcut {
|
||||
// An identical Mac override marks a Mac-only display shortcut.
|
||||
// The portable field remains unchanged for legacy CLI consumers.
|
||||
None
|
||||
} else {
|
||||
self.shortcut
|
||||
}?;
|
||||
if mac {
|
||||
return Some(keys.to_owned());
|
||||
}
|
||||
|
||||
@@ -89,11 +89,11 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
// Alignment
|
||||
CommandSpec {
|
||||
shortcut_mac: Some("Cmd+L"),
|
||||
..cmd!("home.alignLeft", "Align Left", ["Home", "Alignment"], None, "{range?}", has_doc, |s, p| halign(s, p, HAlign::Left))
|
||||
..cmd!("home.alignLeft", "Align Left", ["Home", "Alignment"], Some("Cmd+L"), "{range?}", has_doc, |s, p| halign(s, p, HAlign::Left))
|
||||
},
|
||||
CommandSpec {
|
||||
shortcut_mac: Some("Cmd+E"),
|
||||
..cmd!("home.alignCenter", "Center", ["Home", "Alignment"], None, "{range?}", has_doc, |s, p| halign(s, p, HAlign::Center))
|
||||
..cmd!("home.alignCenter", "Center", ["Home", "Alignment"], Some("Cmd+E"), "{range?}", has_doc, |s, p| halign(s, p, HAlign::Center))
|
||||
},
|
||||
cmd!("home.alignRight", "Align Right", ["Home", "Alignment"], None, "{range?}", has_doc, |s, p| halign(s, p, HAlign::Right)),
|
||||
cmd!("home.justify", "Justify", ["Home", "Alignment"], None, "{range?}", has_doc, |s, p| halign(s, p, HAlign::Justify)),
|
||||
|
||||
@@ -177,7 +177,9 @@ fn command_palette_shortcuts_come_from_engine_metadata() {
|
||||
assert_eq!(command.shortcut_for_platform(false), other.map(str::to_string), "{id}: Windows/Linux");
|
||||
}
|
||||
|
||||
for (id, legacy) in [("data.group", "Alt+Shift+Right"), ("data.ungroup", "Alt+Shift+Left")] {
|
||||
for (id, legacy) in
|
||||
[("data.group", "Alt+Shift+Right"), ("data.ungroup", "Alt+Shift+Left"), ("home.alignLeft", "Cmd+L"), ("home.alignCenter", "Cmd+E")]
|
||||
{
|
||||
let command = commands.iter().find(|c| c.id == id).unwrap();
|
||||
assert_eq!(command.shortcut, Some(legacy), "{id}: legacy CLI shortcut");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user