mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-03 00:41:56 -06:00
fix(ui): correct Paste Special shortcut in command palette
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use super::*;
|
||||
|
||||
/// Shows enabled commands and their platform-specific keyboard shortcuts.
|
||||
pub(super) fn command_search(app: &mut SheetApp, ui: &mut egui::Ui, d: &mut Dialog, confirm: &mut bool) {
|
||||
let (down, up, home, end, pgup, pgdn) = ui.input_mut(|i| {
|
||||
(
|
||||
@@ -70,7 +71,15 @@ pub(super) fn command_search(app: &mut SheetApp, ui: &mut egui::Ui, d: &mut Dial
|
||||
egui::ScrollArea::vertical().max_height(LIST_HEIGHT).auto_shrink([true, false]).show(ui, |ui| {
|
||||
let scroll_area_width = ui.available_width();
|
||||
for (i, (id, label, menu, shortcut)) in cmds.iter().enumerate() {
|
||||
let shortcut = shortcut.map(|keys| if cfg!(target_os = "macos") { keys.to_string() } else { keys.replace("Cmd+", "Ctrl+") });
|
||||
let shortcut = shortcut.map(|keys| {
|
||||
if cfg!(target_os = "macos") {
|
||||
keys.to_string()
|
||||
} else if keys == "Ctrl+Cmd+V" {
|
||||
"Ctrl+Alt+V".to_string()
|
||||
} else {
|
||||
keys.strip_prefix("Cmd+").map_or_else(|| keys.to_string(), |rest| format!("Ctrl+{rest}"))
|
||||
}
|
||||
});
|
||||
let text = match shortcut {
|
||||
Some(keys) => format!("{label} ({keys}) {menu}"),
|
||||
None => format!("{label} {menu}"),
|
||||
|
||||
@@ -83,6 +83,7 @@ fn command_search_arrow_and_page_keys_move_the_selection_and_keep_the_search_foc
|
||||
assert!(h.ctx.memory(|m| m.focused()).is_some(), "the search field kept focus");
|
||||
}
|
||||
|
||||
/// Checks platform-specific labels for the Bold and Filter shortcuts.
|
||||
#[test]
|
||||
fn command_search_shows_shortcuts_for_current_platform() {
|
||||
let mut h = harness();
|
||||
@@ -101,3 +102,22 @@ fn command_search_shows_shortcuts_for_current_platform() {
|
||||
let filter = if cfg!(target_os = "macos") { "Filter (⌘⇧F)" } else { "Filter (Ctrl+Shift+L)" };
|
||||
h.get_by_label_contains(filter);
|
||||
}
|
||||
|
||||
/// Checks that Paste Special shows a usable shortcut after copying a cell.
|
||||
#[test]
|
||||
fn command_search_shows_paste_special_shortcut() {
|
||||
let mut h = harness();
|
||||
|
||||
h.state_mut().session.execute("cell.set", json!({"cell": "C3", "input": "copied"})).unwrap();
|
||||
h.state_mut().session.execute("edit.copy", json!({"range": "C3"})).unwrap();
|
||||
|
||||
h.state_mut().open_dialog("commandSearch", json!({}));
|
||||
h.run_steps(6);
|
||||
|
||||
h.state_mut().dialog.as_mut().unwrap().search = "pasteSpecial".into();
|
||||
h.run_steps(3);
|
||||
|
||||
let expected = if cfg!(target_os = "macos") { "Paste Special… (Ctrl+Cmd+V)" } else { "Paste Special… (Ctrl+Alt+V)" };
|
||||
|
||||
h.get_by_label_contains(expected);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user