mirror of
https://github.com/wez/wezterm.git
synced 2024-12-23 13:21:38 +03:00
properly fix action=wezterm.action.ExtendSelectionToMouseCursor(nil)
ee5206db50
attempted to fix this by
replacing all DynValue::Null values with a special null userdata.
However, a consequence of that is that it broke:
```
window:get_config_overrides() or {}
```
because a userdata is always true, even if it represents a null value.
This commit fixes that case by being selective with the userdata usage:
we only use it when converting the value portion of a table key/value
pair.
refs: #2177
refs: #2200
This commit is contained in:
parent
241e19babf
commit
a34b3ce777
@ -58,12 +58,30 @@ macro_rules! impl_lua_conversion_dynamic {
|
||||
pub fn dynamic_to_lua_value<'lua>(
|
||||
lua: &'lua mlua::Lua,
|
||||
value: DynValue,
|
||||
) -> mlua::Result<mlua::Value> {
|
||||
dynamic_to_lua_value_impl(lua, value, false)
|
||||
}
|
||||
|
||||
pub fn dynamic_to_lua_table_value<'lua>(
|
||||
lua: &'lua mlua::Lua,
|
||||
value: DynValue,
|
||||
) -> mlua::Result<mlua::Value> {
|
||||
dynamic_to_lua_value_impl(lua, value, true)
|
||||
}
|
||||
|
||||
fn dynamic_to_lua_value_impl<'lua>(
|
||||
lua: &'lua mlua::Lua,
|
||||
value: DynValue,
|
||||
is_table_value: bool,
|
||||
) -> mlua::Result<mlua::Value> {
|
||||
Ok(match value {
|
||||
// Use a special userdata as a proxy for Null, because if we are a value
|
||||
// and we use Nil then the key is implicitly deleted and that changes
|
||||
// the representation of the data in unexpected ways
|
||||
DynValue::Null => LuaValue::LightUserData(mlua::LightUserData(std::ptr::null_mut())),
|
||||
DynValue::Null if is_table_value => {
|
||||
LuaValue::LightUserData(mlua::LightUserData(std::ptr::null_mut()))
|
||||
}
|
||||
DynValue::Null => LuaValue::Nil,
|
||||
DynValue::Bool(b) => LuaValue::Boolean(b),
|
||||
DynValue::String(s) => s.to_lua(lua)?,
|
||||
DynValue::U64(u) => u.to_lua(lua)?,
|
||||
@ -81,7 +99,7 @@ pub fn dynamic_to_lua_value<'lua>(
|
||||
for (key, value) in object.into_iter() {
|
||||
table.set(
|
||||
dynamic_to_lua_value(lua, key)?,
|
||||
dynamic_to_lua_value(lua, value)?,
|
||||
dynamic_to_lua_table_value(lua, value)?,
|
||||
)?;
|
||||
}
|
||||
LuaValue::Table(table)
|
||||
|
Loading…
Reference in New Issue
Block a user