aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/typval.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-05-04 16:12:52 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-05-04 16:14:43 +0800
commit47132823ab1c4f458c945df89d12e897d77db8a8 (patch)
treef71b8841ee2b9bd0e7a51e184a64d3117f51cc3d /src/nvim/eval/typval.c
parent7ac63906eae92b5d31fc7e380ef05b8bce73ad8b (diff)
downloadrneovim-47132823ab1c4f458c945df89d12e897d77db8a8.tar.gz
rneovim-47132823ab1c4f458c945df89d12e897d77db8a8.tar.bz2
rneovim-47132823ab1c4f458c945df89d12e897d77db8a8.zip
vim-patch:8.2.3336: behavior of negative index in list change changed
Problem: Behavior of negative index in list change changed. (Naruhiko Nishino) Solution: Only change it for Vim9 script. (closes vim/vim#8749) https://github.com/vim/vim/commit/92f05f21afdb8a43581554a252cb2fc050f9e03b Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/eval/typval.c')
-rw-r--r--src/nvim/eval/typval.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c
index 8028688ac8..0b2be3074f 100644
--- a/src/nvim/eval/typval.c
+++ b/src/nvim/eval/typval.c
@@ -787,15 +787,15 @@ int tv_list_slice_or_index(list_T *list, bool range, int n1_arg, int n2_arg, typ
n1 = len + n1;
}
if (n1 < 0 || n1 >= len) {
- // For a range we allow invalid values and return an empty
- // list. A list index out of range is an error.
+ // For a range we allow invalid values and return an empty list.
+ // A list index out of range is an error.
if (!range) {
if (verbose) {
semsg(_(e_listidx), (int64_t)n1);
}
return FAIL;
}
- n1 = n1 < 0 ? 0 : len;
+ n1 = len;
}
if (range) {
if (n2 < 0) {