diff options
author | ZyX <kp-pav@yandex.ru> | 2014-11-06 17:25:45 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2016-04-18 02:43:43 +0300 |
commit | 1168dbe3435580f872ae9cd44648f3b3a881896c (patch) | |
tree | 5dfec25778321769b1faa235230752d7ac4ac9af | |
parent | 459900b1005d8fd661d03d0e0bdae771a21b017b (diff) | |
download | rneovim-1168dbe3435580f872ae9cd44648f3b3a881896c.tar.gz rneovim-1168dbe3435580f872ae9cd44648f3b3a881896c.tar.bz2 rneovim-1168dbe3435580f872ae9cd44648f3b3a881896c.zip |
option: Add find_key_option_len function
-rw-r--r-- | src/nvim/option.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c index b7521e38f8..f3cd144386 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -4289,7 +4289,7 @@ static void check_redraw(uint32_t flags) * Find index for option 'arg' that has given length. * Return -1 if not found. */ -static int findoption_len(const char_u *const arg, const size_t len) +int findoption_len(const char_u *const arg, const size_t len) { char *s, *p; static short quick_tab[27] = {0, 0}; /* quick access table */ @@ -4670,7 +4670,7 @@ char_u *get_highlight_default(void) /* * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number. */ -static int find_key_option(const char_u *arg) +int find_key_option_len(const char_u *arg, size_t len) { int key; int modifiers; @@ -4679,12 +4679,12 @@ static int find_key_option(const char_u *arg) * Don't use get_special_key_code() for t_xx, we don't want it to call * add_termcap_entry(). */ - if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) + if (len >= 4 && arg[0] == 't' && arg[1] == '_') key = TERMCAP2KEY(arg[2], arg[3]); else { --arg; /* put arg at the '<' */ modifiers = 0; - key = find_special_key(&arg, STRLEN(arg), &modifiers, true, true); + key = find_special_key(&arg, len + 1, &modifiers, true, true); if (modifiers) { // can't handle modifiers here key = 0; } @@ -4692,6 +4692,12 @@ static int find_key_option(const char_u *arg) return key; } +static int find_key_option(const char_u *arg) +{ + return find_key_option_len(arg, STRLEN(arg)); +} + + /* * if 'all' == 0: show changed options * if 'all' == 1: show all normal options |