From d523750de0b3e753dcef20ca3fb622b015a307da Mon Sep 17 00:00:00 2001 From: ncrpy <61719652+ncrpy@users.noreply.github.com> Date: Mon, 7 Jul 2025 14:03:09 +0900 Subject: [PATCH] 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 ``, the API will now correctly return both `lhsraw` (`<80>^DX`) and `lhsrawalt` (the alternate form, e.g., `^X`). --- src/nvim/mapping.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c index 98f9cd04e4..fd97bfc18b 100644 --- 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))); } }