From 9c3a6976f058a095318c0ca0ce0d9ea9158e9ccb Mon Sep 17 00:00:00 2001 From: Matt Lauber Date: Fri, 16 Dec 2016 18:58:45 +0100 Subject: [PATCH] #2312 Prevent move filter from wrapping (#2658) given a list `A B C D` if I run `A B C D +[move:-1 [A]]` I get `B C A D`. However, if I were to do `A B C D +[move:1[D]]` it doesn't wrap around, and I get `A B C D`. This fixes that such that `A B C D +[move:-1 [A]]` gives 'A B C D` --- core/modules/filters/x-listops.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/modules/filters/x-listops.js b/core/modules/filters/x-listops.js index a20fd5646..3d1f8c506 100644 --- a/core/modules/filters/x-listops.js +++ b/core/modules/filters/x-listops.js @@ -84,8 +84,9 @@ Extended filter operators to manipulate the current list. var results = prepare_results(source), index = results.indexOf(operator.operand), count = parseInt(operator.suffix) || 1, - marker = results.splice(index, 1); - return results.slice(0, index + count).concat(marker).concat(results.slice(index + count)); + marker = results.splice(index, 1), + offset = (index + count) > 0 ? index + count : 0; + return results.slice(0, offset).concat(marker).concat(results.slice(offset)); }; /*