aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/private/helpers.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-05-12 13:24:20 +0200
committerJustin M. Keyes <justinkz@gmail.com>2019-05-12 13:27:07 +0200
commit60aaae1c8616a9b32dfed835f9857c72ecaedf73 (patch)
tree4bad68d868871f00041e72bdf81f5f714aa020a9 /src/nvim/api/private/helpers.c
parentf35d233e077539a4ae8591a7a05b4df0f3d598d3 (diff)
downloadrneovim-60aaae1c8616a9b32dfed835f9857c72ecaedf73.tar.gz
rneovim-60aaae1c8616a9b32dfed835f9857c72ecaedf73.tar.bz2
rneovim-60aaae1c8616a9b32dfed835f9857c72ecaedf73.zip
API/nvim_set_keymap: remove mode-shortname aliases
Reduce the API surface-area a bit. No need to have aliases for a mode. ref #9924
Diffstat (limited to 'src/nvim/api/private/helpers.c')
-rw-r--r--src/nvim/api/private/helpers.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index 2bd51f71d7..521ec11906 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -797,15 +797,14 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs,
mode_val = get_map_mode(&p, true); // mapmode-ic
} else {
mode_val = get_map_mode(&p, false);
- if (mode_val == VISUAL + SELECTMODE + NORMAL + OP_PENDING) {
- // get_map_mode will treat "unrecognized" mode shortnames like "map"
- // if it does, and the given shortname wasn't "m" or " ", then error
- if (STRNCMP(p, "m", 2) && STRNCMP(p, " ", 2)) {
- err_msg = "Invalid mode shortname: %s";
- err_arg = (char *)p;
- err_type = kErrorTypeValidation;
- goto fail_with_message;
- }
+ if ((mode_val == VISUAL + SELECTMODE + NORMAL + OP_PENDING)
+ && mode.size > 0) {
+ // get_map_mode() treats unrecognized mode shortnames as ":map".
+ // This is an error unless the given shortname was empty string "".
+ err_msg = "Invalid mode shortname: \"%s\"";
+ err_arg = (char *)p;
+ err_type = kErrorTypeValidation;
+ goto fail_with_message;
}
}