You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/specs/#6899 - Action IDs/#6899 - Action IDs.md
+44-25
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ contexts without needing to replicate an entire json blob.
23
23
24
24
This spec was largely inspired by the following diagram from @DHowett:
25
25
26
-

26
+

27
27
28
28
The goal is to introduce an `id` parameter by which actions could be uniquely
29
29
referred to. If we'd ever like to use an action outside the list of `actions`, we
@@ -36,38 +36,54 @@ Discussion with the team lead to the understanding that the name `actions` would
36
36
be even better, as a way of making the meaning of the "list of actions" more
37
37
obvious.
38
38
39
-
When we're parsing `actions`, we'll make three passes:
40
-
* The first pass will scan the list for objects with an `id` property. We'll
39
+
We will then restructure `defaults.json`, and also users' settings files (via `fixUpUserSettings`), in the following manner:
40
+
* Instead of each `command` json block containing both the `action` (along with additional arguments) and the `keys`, these will now be split up -
41
+
* There will now be one json block for just the `command`/`action`, which will also contain the `id`. These json blocks will be in their own list called `actions`.
42
+
* There will be another json block for the `keys`, which will refer to the action to be invoked by `id`. These json blocks will be in their own list called `keybindings`.
43
+
44
+
For example, let's take a look at the `split pane right` action in `defaults.json` as we currently have it:
Here is how we will parse settings file and construct the relevant settings model objects:
55
+
* We will first scan the `actions` list. We'll
41
56
attempt to parse those entries into `ActionAndArgs` which we'll store in the
42
-
global `id->ActionAndArgs` map. If any entry doesn't have an `id` set, we'll
43
-
skip it in this phase. If an entry doesn't have a `command` set, we'll ignore
44
-
it in this pass.
45
-
* The second pass will scan for _keybindings_. Any entries with `keys` set will
46
-
create a `KeyChord->ActionAndArgs` entry in the keybindings map. If the entry
47
-
has an `id` set, then we'll simply re-use the action we've already parsed for
48
-
the `id`, from the action map. If there isn't an `id`, then we'll parse the
49
-
action manually at this time. Entries without a `keys` set will be ignored in
50
-
this pass.
51
-
* The final pass will be to generate _commands_. Similar to the keybindings
52
-
pass, we'll attempt to lookup actions for entries with an `id` set. If there
53
-
isn't an `id`, then we'll parse the action manually at this time. We'll then
54
-
get the name for the entry, either from the `name` property if it's set, or
55
-
the action's `GenerateName` method.
57
+
global `id->ActionAndArgs` map. All actions defined in `defaults.json` must have an `id` specified, and all actions provided by fragments must also have `id`s. Any actions from the defaults or fragments that do not provide `id`s will be ignored. As for user-specified commands, if no `id` is set, we will auto-generate one for that command based on the action and any additional arguments. For example, the `split pane right` command above might result in an autogenerated id `User.SplitPaneRight`.
58
+
* Note: this step is also where we will generate _commands_. We will use the name provided in the entry if it's set or the action's `GenerateName` method.
59
+
* Next we will scan the `keybindings` list. These entries will
60
+
create a `KeyChord->ActionAndArgs` entry in the keybindings map. Since these objects should all contain an `id`, we will simply use the `id->ActionAndArgs` map we created in the previous step. Any object with `keys` set but no `id` will be ignored.
56
61
57
-
For a visual representation, let's assume the user has the following in their
For this case, having an `id` on the top level could potentially make sense when it comes to using that `id` in a menu, but not in the case of using that `id` for a keybinding. For the initial implementation, we will not support an `id` for these types of actions, which leaves us open to revisiting this in the future.
70
85
86
+
### Layering
71
87
72
88
When layering `actions`, if a later settings file contains an action with the
73
89
same `id`, it will replace the current value. In this way, users can redefine
@@ -87,6 +103,9 @@ As we add additional menus to the Terminal, like the customization for the new
87
103
tab dropdown, or the tab context menu, or the `TermControl` context menu, they
88
104
could all refer to these actions by `id`, rather than duplicating the same json.
89
105
106
+
As for fragments, all actions in fragments _must_ have an `id`. If a fragment provides an action without an `id`, or provides an `id` that clashes with one of the actions in `defaults.json`, that action will be ignored.
107
+
108
+
> 👉 NOTE: This will mean that actions will now need an `OriginTag`, similar to profiles and color schemes
0 commit comments