mirror of
https://github.com/neovim/neovim.git
synced 2025-10-15 14:26:07 +00:00
@@ -770,7 +770,7 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs,
|
||||
MapArguments parsed_args;
|
||||
memset(&parsed_args, 0, sizeof(parsed_args));
|
||||
if (parse_keymap_opts(opts, &parsed_args, err)) {
|
||||
goto FAIL_AND_FREE;
|
||||
goto fail_and_free;
|
||||
}
|
||||
parsed_args.buffer = !global;
|
||||
|
||||
@@ -782,14 +782,14 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs,
|
||||
err_msg = "LHS exceeds maximum map length: %s";
|
||||
err_arg = lhs.data;
|
||||
err_type = kErrorTypeValidation;
|
||||
goto FAIL_WITH_MESSAGE;
|
||||
goto fail_with_message;
|
||||
}
|
||||
|
||||
if (mode.size > 1) {
|
||||
err_msg = "Shortname is too long: %s";
|
||||
err_arg = mode.data;
|
||||
err_type = kErrorTypeValidation;
|
||||
goto FAIL_WITH_MESSAGE;
|
||||
goto fail_with_message;
|
||||
}
|
||||
int mode_val; // integer value of the mapping mode, to be passed to do_map()
|
||||
char_u *p = (char_u *)((mode.size) ? mode.data : "m");
|
||||
@@ -804,7 +804,7 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs,
|
||||
err_msg = "Invalid mode shortname: %s";
|
||||
err_arg = (char *)p;
|
||||
err_type = kErrorTypeValidation;
|
||||
goto FAIL_WITH_MESSAGE;
|
||||
goto fail_with_message;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -813,7 +813,7 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs,
|
||||
err_msg = "Invalid (empty) LHS";
|
||||
err_arg = "";
|
||||
err_type = kErrorTypeValidation;
|
||||
goto FAIL_WITH_MESSAGE;
|
||||
goto fail_with_message;
|
||||
}
|
||||
|
||||
bool is_noremap = parsed_args.noremap;
|
||||
@@ -829,16 +829,16 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs,
|
||||
err_msg = "Parsing of nonempty RHS failed: %s";
|
||||
err_arg = rhs.data;
|
||||
err_type = kErrorTypeException;
|
||||
goto FAIL_WITH_MESSAGE;
|
||||
goto fail_with_message;
|
||||
}
|
||||
} else if (is_unmap && parsed_args.rhs_len) {
|
||||
err_msg = "Gave nonempty RHS in unmap command: %s";
|
||||
err_arg = (char *)parsed_args.rhs;
|
||||
err_type = kErrorTypeValidation;
|
||||
goto FAIL_WITH_MESSAGE;
|
||||
goto fail_with_message;
|
||||
}
|
||||
|
||||
// buf_do_map_explicit reads noremap/unmap as its own argument
|
||||
// buf_do_map() reads noremap/unmap as its own argument.
|
||||
int maptype_val = 0;
|
||||
if (is_unmap) {
|
||||
maptype_val = 1;
|
||||
@@ -846,23 +846,22 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs,
|
||||
maptype_val = 2;
|
||||
}
|
||||
|
||||
switch (buf_do_map_explicit(maptype_val, &parsed_args, mode_val,
|
||||
0, target_buf)) {
|
||||
switch (buf_do_map(maptype_val, &parsed_args, mode_val, 0, target_buf)) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
api_set_error(err, kErrorTypeException, (char *)e_invarg, 0);
|
||||
goto FAIL_AND_FREE;
|
||||
goto fail_and_free;
|
||||
case 2:
|
||||
api_set_error(err, kErrorTypeException, (char *)e_nomap, 0);
|
||||
goto FAIL_AND_FREE;
|
||||
goto fail_and_free;
|
||||
case 5:
|
||||
api_set_error(err, kErrorTypeException,
|
||||
"E227: mapping already exists for %s", parsed_args.lhs);
|
||||
goto FAIL_AND_FREE;
|
||||
goto fail_and_free;
|
||||
default:
|
||||
assert(false && "Unrecognized return code!");
|
||||
goto FAIL_AND_FREE;
|
||||
goto fail_and_free;
|
||||
} // switch
|
||||
|
||||
xfree(lhs_buf);
|
||||
@@ -872,10 +871,10 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs,
|
||||
|
||||
return;
|
||||
|
||||
FAIL_WITH_MESSAGE:
|
||||
fail_with_message:
|
||||
api_set_error(err, err_type, err_msg, err_arg);
|
||||
|
||||
FAIL_AND_FREE:
|
||||
fail_and_free:
|
||||
xfree(lhs_buf);
|
||||
xfree(rhs_buf);
|
||||
xfree(parsed_args.rhs);
|
||||
@@ -913,7 +912,7 @@ Integer parse_keymap_opts(Dictionary opts, MapArguments *out, Error *err)
|
||||
err_msg = "Gave non-boolean value for an opt: %s";
|
||||
err_arg = optname;
|
||||
err_type = kErrorTypeValidation;
|
||||
goto FAIL_WITH_MESSAGE;
|
||||
goto fail_with_message;
|
||||
}
|
||||
|
||||
bool was_valid_opt = false;
|
||||
@@ -961,13 +960,13 @@ Integer parse_keymap_opts(Dictionary opts, MapArguments *out, Error *err)
|
||||
err_msg = "Invalid key: %s";
|
||||
err_arg = optname;
|
||||
err_type = kErrorTypeValidation;
|
||||
goto FAIL_WITH_MESSAGE;
|
||||
goto fail_with_message;
|
||||
}
|
||||
} // for
|
||||
|
||||
return 0;
|
||||
|
||||
FAIL_WITH_MESSAGE:
|
||||
fail_with_message:
|
||||
api_set_error(err, err_type, err_msg, err_arg);
|
||||
return 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user