aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/typval.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-09-12 17:10:31 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-09-12 17:28:07 +0800
commit245ac6f263b6017c050f885212ee80e5738d3b9f (patch)
treeca90a565370f46fd84ddf052c5769e04ede33e00 /src/nvim/eval/typval.c
parent4448fa88ecca11acd4742ef3d38f9e0d42c0b4a5 (diff)
downloadrneovim-245ac6f263b6017c050f885212ee80e5738d3b9f.tar.gz
rneovim-245ac6f263b6017c050f885212ee80e5738d3b9f.tar.bz2
rneovim-245ac6f263b6017c050f885212ee80e5738d3b9f.zip
vim-patch:8.2.5034: there is no way to get the byte index from a virtual column
Problem: There is no way to get the byte index from a virtual column. Solution: Add virtcol2col(). (Yegappan Lakshmanan, closes vim/vim#10477, closes vim/vim#10098) https://github.com/vim/vim/commit/5a6ec10cc80ab02eeff644ab19b82312630ea855 Cherry-pick tv_check_for_number_arg() from Vim. Cherry-pick pathshorten() doc change.
Diffstat (limited to 'src/nvim/eval/typval.c')
-rw-r--r--src/nvim/eval/typval.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c
index c75d16e4fc..2089415ffa 100644
--- a/src/nvim/eval/typval.c
+++ b/src/nvim/eval/typval.c
@@ -44,6 +44,8 @@ static char e_string_required_for_argument_nr[]
= N_("E1174: String required for argument %d");
static char e_non_empty_string_required_for_argument_nr[]
= N_("E1142: Non-empty string required for argument %d");
+static char e_number_required_for_argument_nr[]
+ = N_("E1210: Number required for argument %d");
bool tv_in_free_unref_items = false;
@@ -3830,6 +3832,17 @@ int tv_check_for_nonempty_string_arg(const typval_T *const args, const int idx)
return OK;
}
+/// Give an error and return FAIL unless "args[idx]" is a number.
+int tv_check_for_number_arg(const typval_T *const args, const int idx)
+ FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE
+{
+ if (args[idx].v_type != VAR_NUMBER) {
+ semsg(_(e_number_required_for_argument_nr), idx + 1);
+ return FAIL;
+ }
+ return OK;
+}
+
/// Get the string value of a "stringish" VimL object.
///
/// @param[in] tv Object to get value of.