commit d523750de0b3e753dcef20ca3fb622b015a307da
parent c3c8d25293fd4da8fa867d18a7d54b2dc8c3d010
Author: ncrpy <61719652+ncrpy@users.noreply.github.com>
Date: Mon, 7 Jul 2025 14:03:09 +0900
fix(api): populate lhsrawalt in nvim_get_keymap response
Problem:
The `nvim_get_keymap()` function is missing the `lhsrawalt` field in its response for mappings with an alternate key representation. This makes its return value inconsistent with its documented `maparg()`-like structure and its formal type definition.
Solution:
Corrects the `keymap_array` function to pass the alternate mapping keys (`current_maphash->m_alt->m_keys`) to `mapblock_fill_dict`. The argument responsible for this was previously hardcoded to `NULL`.
For example, for a mapping of `<C-x>`, the API will now correctly return both `lhsraw` (`<80><fc>^DX`) and `lhsrawalt` (the alternate form, e.g., `^X`).
Diffstat:
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c
@@ -2894,7 +2894,10 @@ ArrayOf(Dict) keymap_array(String mode, buf_T *buf, Arena *arena)
}
// Check for correct mode
if (int_mode & current_maphash->m_mode) {
- kvi_push(mappings, DICT_OBJ(mapblock_fill_dict(current_maphash, NULL, buffer_value,
+ kvi_push(mappings, DICT_OBJ(mapblock_fill_dict(current_maphash,
+ current_maphash->m_alt
+ ? current_maphash->m_alt->m_keys : NULL,
+ buffer_value,
is_abbrev, false, arena)));
}
}