diff options
| author | Frank LENORMAND <lenormf@gmail.com> | 2019-06-24 18:17:49 +0300 |
|---|---|---|
| committer | Frank LENORMAND <lenormf@gmail.com> | 2019-06-24 18:17:49 +0300 |
| commit | 4c7bc9179b1675a362b360d7cbfa7157eb62df90 (patch) | |
| tree | 6799c89842964d6d1444cc7892e3132c32ab18d8 /src | |
| parent | 6e09f677f4d0663e05039f9368b9dbfdb93c28b4 (diff) | |
src: Enforce case sensitivity when parsing function keys
The `parse_keys()` function is case insensitive when parsing function keys,
while the `key_to_str()` function always returns a capitalized key
description.
When users hook on the lowercase name of a function key,
e.g. `NormalKey <f10>`, and later hit that same key in normal mode, the
`key_to_str()` will convert it to the uppercase description ("<F10>").
This results into a hook with a lowercase regex predicate being unsuccessfully
matched against an uppercase key description by the hook manager, which
works on a case sensitive basis.
One solution could be to uppercase all function key descriptions passed as
hook filter upon declaration, but detecting that is not trivial as the
filter can contain more than just the simple <f\d+> data, e.g.
---
hook global InsertKey '<(?<name>\w+)>' %{…}
---
Another simpler solution that this commit implements is to allow only <F\d+>
descriptions in `parse_keys()`, and hope users will know not to use the
lowercase notation when declaring hooks.
Fixes #2907
Diffstat (limited to 'src')
| -rw-r--r-- | src/keys.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/keys.cc b/src/keys.cc index e624767c..edbd5e0c 100644 --- a/src/keys.cc +++ b/src/keys.cc @@ -126,7 +126,7 @@ KeyList parse_keys(StringView str) result.push_back(canonicalize_ifn({ modifier, name_it->key })); else if (desc.char_length() == 1) result.push_back(canonicalize_ifn({ modifier, desc[0_char] })); - else if (to_lower(desc[0_byte]) == 'f' and desc.length() <= 3) + else if (desc[0_byte] == 'F' and desc.length() <= 3) { int val = str_to_int(desc.substr(1_byte)); if (val >= 1 and val <= 12) |
