Compare commits

...

1 Commits

Author SHA1 Message Date
João Marcos
656970488f temporary commit: experiment with how we define deprecated actions 2025-02-28 13:17:21 -03:00
3 changed files with 36 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
//! This module contains all actions supported by [`Editor`].
use super::*;
use gpui::{action_as, action_with_deprecated_aliases};
use gpui::{action_as, actions_with_deprecated_aliases};
use schemars::JsonSchema;
use util::serde::default_true;
#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema)]
@@ -426,6 +426,20 @@ gpui::actions!(
action_as!(go_to_line, ToggleGoToLine as Toggle);
action_with_deprecated_aliases!(editor, OpenSelectedFilename, ["editor::OpenFile"]);
action_with_deprecated_aliases!(editor, ToggleSelectedDiffHunks, ["editor::ToggleHunkDiff"]);
action_with_deprecated_aliases!(editor, ExpandAllDiffHunks, ["editor::ExpandAllHunkDiffs"]);
// TODO: dedup editor
// TODO: make it in a way this is formated as expected, maybe use tuples here? don't know if it's possible nope
actions_with_deprecated_aliases!(
editor,
OpenSelectedFilename,
["editor::OpenFile"],
editor,
ToggleSelectedDiffHunks,
["editor::ToggleHunkDiff"],
editor,
ExpandAllDiffHunks,
["editor::ExpandAllHunkDiffs"],
);
pub fn show_it() {
dbg!(DEPRECATED_ALIASES);
}

View File

@@ -2048,6 +2048,7 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) {
crate::actions::show_it();
window.invalidate_character_coordinates();
// Copy selections to primary selection buffer

View File

@@ -357,6 +357,23 @@ macro_rules! action_as {
};
}
/// Same as `action_with_deprecated_aliases`, but, also creates a const array of all deprecated
/// aliases it has seen.
#[macro_export]
macro_rules! actions_with_deprecated_aliases {
( $( $namespace:path, $name:ident, [$($alias:literal),* $(,)?] ),* $(,)? ) => {
$(
// Use action_with_deprecated_aliases for each action
gpui::action_with_deprecated_aliases!($namespace, $name, [$($alias),*]);
)*
// Create a static array with all deprecated aliases
pub const DEPRECATED_ALIASES: &[&str] = &[
$( $( $alias ),* ),*
];
};
}
/// Defines and registers a unit struct that can be used as an action, with some deprecated aliases.
#[macro_export]
macro_rules! action_with_deprecated_aliases {