Use id instead of type_id for actions

Currently, both are the same thing, so the logic is not changed.
This commit is contained in:
Kirill Bulatov 2023-07-17 12:24:56 +03:00
parent 10a1df3faa
commit eaa8224076
5 changed files with 30 additions and 37 deletions

View file

@ -1073,7 +1073,7 @@ impl AppContext {
pub fn is_action_available(&self, action: &dyn Action) -> bool {
let mut available_in_window = false;
let action_type = action.as_any().type_id();
let action_id = action.id();
if let Some(window_id) = self.platform.main_window_id() {
available_in_window = self
.read_window(window_id, |cx| {
@ -1083,7 +1083,7 @@ impl AppContext {
cx.views_metadata.get(&(window_id, view_id))
{
if let Some(actions) = cx.actions.get(&view_metadata.type_id) {
if actions.contains_key(&action_type) {
if actions.contains_key(&action_id) {
return true;
}
}
@ -1094,7 +1094,7 @@ impl AppContext {
})
.unwrap_or(false);
}
available_in_window || self.global_actions.contains_key(&action_type)
available_in_window || self.global_actions.contains_key(&action_id)
}
fn actions_mut(
@ -3399,7 +3399,7 @@ impl<'a, 'b, 'c, V: View> LayoutContext<'a, 'b, 'c, V> {
for (i, view_id) in self.ancestors(view_id).enumerate() {
if let Some(view_metadata) = self.views_metadata.get(&(window_id, view_id)) {
if let Some(actions) = self.actions.get(&view_metadata.type_id) {
if actions.contains_key(&action.as_any().type_id()) {
if actions.contains_key(&action.id()) {
handler_depth = Some(i);
}
}
@ -3407,12 +3407,12 @@ impl<'a, 'b, 'c, V: View> LayoutContext<'a, 'b, 'c, V> {
}
}
if self.global_actions.contains_key(&action.as_any().type_id()) {
if self.global_actions.contains_key(&action.id()) {
handler_depth = Some(contexts.len())
}
self.keystroke_matcher
.bindings_for_action_type(action.as_any().type_id())
.bindings_for_action(action.id())
.find_map(|b| {
let highest_handler = handler_depth?;
if action.eq(b.action())