fix(ui): correct Paste Special shortcut in command palette

This commit is contained in:
AnhNgoo
2026-10-28 08:13:33 +07:00
parent d3832e98e6
commit 6e7fb6ce0b
2 changed files with 30 additions and 1 deletions
+10 -1
View File
@@ -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}"),
+20
View File
@@ -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);
}