Skip to content

Bug when rearranging #3

Open
Open
@Nikhilkranthi

Description

@Nikhilkranthi

Let us consider this code

import (
	"fmt"

	"github.com/herkyl/patchwerk"
)

func main() {
	a := `{"L1": ["A", "B","C"]}`
	b := `{"L1": ["C", "A","B"]}`
	patch, err := patchwerk.DiffBytes([]byte(a), []byte(b))
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(string(patch))
}

Output:
[{"op":"add","path":"/L1/0","value":"C"}]'

But the actual output of the patch should be
[{remove /L1/2 } {add /L1/0 C}]
Where C at index 2 is removed and C is added at index 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions