1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-22 22:42:48 +03:00

ActivateKeyTable replace_current wasn't actually optional

The issue here was that the from_dynamic impl derived for a struct
that was inlined in an enum didn't respect the the field properties
defined for the struct.

Refactor to reuse the same field_info helper used by the struct
code.

Update docs to clarify what the default value actually is.

refs: https://github.com/wez/wezterm/issues/2179
This commit is contained in:
Wez Furlong 2022-06-25 19:38:39 -07:00
parent cf4d5de854
commit f2627bc39e
3 changed files with 5 additions and 15 deletions

View File

@ -11,7 +11,8 @@ usually the best available version.
As features stabilize some brief notes about them will accumulate here. As features stabilize some brief notes about them will accumulate here.
* Not yet #### Fixed
* [ActivateKeyTable](config/lua/keyassignment/ActivateKeyTable.md)'s `replace_current` field was not actually optional. Made it optional. [#2179](https://github.com/wez/wezterm/issues/2179)
### 20220624-141144-bd1b7c5d ### 20220624-141144-bd1b7c5d

View File

@ -11,4 +11,4 @@ The following parameters are possible:
* `name` - the name of the table to activate. The name must match up to an entry in the `key_tables` configuration. * `name` - the name of the table to activate. The name must match up to an entry in the `key_tables` configuration.
* `timeout_milliseconds` - an optional duration expressed in milliseconds. If specified, then the activation will automatically expire and pop itself from the key table stack once that duration elapses. If omitted, this activation will not expire due to time. * `timeout_milliseconds` - an optional duration expressed in milliseconds. If specified, then the activation will automatically expire and pop itself from the key table stack once that duration elapses. If omitted, this activation will not expire due to time.
* `one_shot` - an optional boolean that controls whether the activation will pop itself after a single additional key press. The default if left unspecified is `one_shot=true`. When set to `false`, pressing a key will not automatically pop the activation and you will need to use either a timeout or an explicit key assignment that triggers [PopKeyTable](PopKeyTable.md) to cancel the activation. * `one_shot` - an optional boolean that controls whether the activation will pop itself after a single additional key press. The default if left unspecified is `one_shot=true`. When set to `false`, pressing a key will not automatically pop the activation and you will need to use either a timeout or an explicit key assignment that triggers [PopKeyTable](PopKeyTable.md) to cancel the activation.
* `replace_current` - an optional boolean. If set to true then behave as though [PopKeyTable](PopKeyTable.md) was triggered before pushing this new activation on the stack. This is most useful for key assignments in a table that was activated using `one_shot=false`. * `replace_current` - an optional boolean. Defaults to `false` is unspecified. If set to `true` then behave as though [PopKeyTable](PopKeyTable.md) was triggered before pushing this new activation on the stack. This is most useful for key assignments in a table that was activated using `one_shot=false`.

View File

@ -205,19 +205,8 @@ fn derive_enum(input: &DeriveInput, enumeration: &DataEnum) -> Result<TokenStrea
.named .named
.iter() .iter()
.map(|f| { .map(|f| {
let ident = f.ident.as_ref().unwrap(); let info = attr::field_info(f).unwrap();
let name = ident.to_string(); info.from_dynamic(&literal)
let ty = &f.ty;
quote!(
#ident: <#ty>::from_dynamic(
obj.get_by_str(#name).unwrap_or(&Value::Null),
options
).map_err(|source| source.field_context(
#literal,
#name,
obj
))?,
)
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();