From 47132823ab1c4f458c945df89d12e897d77db8a8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 4 May 2023 16:12:52 +0800 Subject: 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 --- src/nvim/eval/typval.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/eval/typval.c') 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) { -- cgit