aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/math.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/math.c')
-rw-r--r--src/nvim/math.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/nvim/math.c b/src/nvim/math.c
index 4ca212413b..0b5886d36c 100644
--- a/src/nvim/math.c
+++ b/src/nvim/math.c
@@ -106,3 +106,9 @@ int vim_append_digit_int(int *value, int digit)
*value = x * 10 + digit;
return OK;
}
+
+/// Return something that fits into an int.
+int trim_to_int(int64_t x)
+{
+ return x > INT_MAX ? INT_MAX : x < INT_MIN ? INT_MIN : (int)x;
+}