From 31bd2b5be055553c7dc32d8653a92eb3524b22f7 Mon Sep 17 00:00:00 2001 From: Daniel Schmidt Date: Wed, 14 Feb 2024 18:08:58 +0100 Subject: [PATCH] plan: compare individual elements if list is same length Closes #33779 --- internal/command/jsonformat/collections/slice.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/command/jsonformat/collections/slice.go b/internal/command/jsonformat/collections/slice.go index 9277530a4d..b52cc7d6c0 100644 --- a/internal/command/jsonformat/collections/slice.go +++ b/internal/command/jsonformat/collections/slice.go @@ -35,6 +35,16 @@ func TransformSlice[Input any](before, after []Input, process TransformIndices, } func ProcessSlice[Input any](before, after []Input, process ProcessIndices, isObjType IsObjType[Input]) { + // If before and after are the same length we want to compare elements + // on an individual basis + + if len(before) == len(after) { + for ix := range before { + process(ix, ix) + } + return + } + lcs := objchange.LongestCommonSubsequence(before, after, func(before, after Input) bool { return reflect.DeepEqual(before, after) })