From 0ea7e45bc1d1881f505da2b77e0b3e4eb56f12fe Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 2 Jul 2017 13:21:38 +0200 Subject: 'cpoptions': remove "<" flag; ignore Closes #6937 "nvim_get_keymap output is unreliable" --- src/nvim/keymap.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/nvim/keymap.c') diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c index ee67b4c19d..295f246126 100644 --- a/src/nvim/keymap.c +++ b/src/nvim/keymap.c @@ -756,9 +756,9 @@ int get_mouse_button(int code, bool *is_click, bool *is_drag) /// Replace any terminal code strings with the equivalent internal /// representation /// -/// This is used for the "from" and "to" part of a mapping, and the "to" part of +/// Used for the "from" and "to" part of a mapping, and the "to" part of /// a menu command. Any strings like "" are also replaced, unless -/// 'cpoptions' contains '<'. K_SPECIAL by itself is replaced by K_SPECIAL +/// `special` is false. K_SPECIAL by itself is replaced by K_SPECIAL /// KS_SPECIAL KE_FILLER. /// /// @param[in] from What characters to replace. @@ -771,7 +771,7 @@ int get_mouse_button(int code, bool *is_click, bool *is_drag) /// When cpo_flags contains #FLAG_CPO_BSLASH, a backslash /// can be used in place of . All other /// characters are removed. -/// @param[in] special If true, always accept notation. +/// @param[in] special Replace keycodes, e.g. becomes a "\n" char. /// @param[in] cpo_flags Relevant flags derived from p_cpo, see /// #CPO_TO_CPO_FLAGS. /// @@ -790,11 +790,9 @@ char_u *replace_termcodes(const char_u *from, const size_t from_len, const char_u *src; const char_u *const end = from + from_len - 1; int do_backslash; // backslash is a special character - int do_special; // recognize <> key codes char_u *result; // buffer for resulting string do_backslash = !(cpo_flags&FLAG_CPO_BSLASH); - do_special = !(cpo_flags&FLAG_CPO_SPECI) || special; // Allocate space for the translation. Worst case a single character is // replaced by 6 bytes (shifted special key), plus a NUL at the end. @@ -817,9 +815,8 @@ char_u *replace_termcodes(const char_u *from, const size_t from_len, // Copy each byte from *from to result[dlen] while (src <= end) { - // If 'cpoptions' does not contain '<', check for special key codes, - // like "" - if (do_special && (do_lt || ((end - src) >= 3 + // Check for special <> keycodes, like "" + if (special && (do_lt || ((end - src) >= 3 && STRNCMP(src, "", 4) != 0))) { // Replace by K_SNR _. // (room: 5 * 6 = 30 bytes; needed: 3 + + 1 <= 14) @@ -846,7 +843,7 @@ char_u *replace_termcodes(const char_u *from, const size_t from_len, } } - if (do_special) { + if (special) { char_u *p, *s, len; // Replace by the value of "mapleader". -- cgit From 829e1f2c43f84caa74c68e8a473d5faf8ec96c48 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 8 Jul 2017 16:17:21 +0200 Subject: lint --- src/nvim/keymap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/keymap.c') diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c index 295f246126..3d7ebb6382 100644 --- a/src/nvim/keymap.c +++ b/src/nvim/keymap.c @@ -817,7 +817,7 @@ char_u *replace_termcodes(const char_u *from, const size_t from_len, while (src <= end) { // Check for special <> keycodes, like "" if (special && (do_lt || ((end - src) >= 3 - && STRNCMP(src, "", 4) != 0))) { + && STRNCMP(src, "", 4) != 0))) { // Replace by K_SNR _. // (room: 5 * 6 = 30 bytes; needed: 3 + + 1 <= 14) if (end - src >= 4 && STRNICMP(src, "", 5) == 0) { -- cgit