Skip to content

Commit a4b5b0e

Browse files
committed
Keep shortcut selected when clearing filter
1 parent 9dde568 commit a4b5b0e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

editor/settings/editor_settings_dialog.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,11 @@ void EditorSettingsDialog::_update_shortcuts() {
518518
}
519519
}
520520

521+
String prev_selected_shortcut;
522+
if (shortcuts->get_selected()) {
523+
prev_selected_shortcut = shortcuts->get_selected()->get_text(0);
524+
}
525+
521526
shortcuts->clear();
522527

523528
TreeItem *root = shortcuts->create_item();
@@ -557,6 +562,9 @@ void EditorSettingsDialog::_update_shortcuts() {
557562

558563
TreeItem *item = _create_shortcut_treeitem(common_section, action_name, action_name, action_events, !same_as_defaults, true, collapse);
559564
item->set_auto_translate_mode(0, AUTO_TRANSLATE_MODE_DISABLED); // `ui_*` input action names are untranslatable identifiers.
565+
if (!prev_selected_shortcut.is_empty() && action_name == prev_selected_shortcut) {
566+
item->select(0);
567+
}
560568
}
561569

562570
// Editor Shortcuts
@@ -616,7 +624,14 @@ void EditorSettingsDialog::_update_shortcuts() {
616624
bool same_as_defaults = Shortcut::is_event_array_equal(original, shortcuts_array);
617625
bool collapse = !collapsed.has(E) || (collapsed.has(E) && collapsed[E]);
618626

619-
_create_shortcut_treeitem(section, E, sc->get_name(), shortcuts_array, !same_as_defaults, false, collapse);
627+
TreeItem *shortcut_item = _create_shortcut_treeitem(section, E, sc->get_name(), shortcuts_array, !same_as_defaults, false, collapse);
628+
if (!prev_selected_shortcut.is_empty() && sc->get_name() == prev_selected_shortcut) {
629+
shortcut_item->select(0);
630+
}
631+
}
632+
633+
if (!prev_selected_shortcut.is_empty()) {
634+
shortcuts->ensure_cursor_is_visible();
620635
}
621636

622637
// remove sections with no shortcuts

0 commit comments

Comments
 (0)