Skip to content

paredit fns that use internal global-find-by-node do not work after zipper updated #256

Closed
@mrkam2

Description

@mrkam2

Version
rewrite-clj/rewrite-clj {:mvn/version "1.1.47"}

Platform
Clojure version: 1.11.1

Symptom
Two issues:

  1. When using rewrite-clj.paredit/kill incorrectly positions the zipper after performing the operation.
  2. Docstring says that it should be removing nodes to the right from the current node. But in fact it deletes nodes starting from the current node.

Reproduction

(-> (z/of-string "[1 2 3 4]")
    z/down
    (z/insert-left (n/keyword-node :wrong-pos))
    z/next
    (z/insert-left (n/keyword-node :nil-meta))
    pe/kill
    z/print)
:wrong-pos

Actual behavior

  1. Positions zipper on the :wrong-pos.
  2. End result is [:wrong-pos 1 :nil-meta ].

Expected behavior

  1. Expected to position on 2.
  2. Expected end result is [:wrong-pos 1 :nil-meta 2]

Diagnosis

  1. Incorrect positioning is caused by global-find-by-node search that compares nodes meta not taking into account that new nodes have nil meta.
  2. Either docstring or the behavior needs to be fixed to match each other.

Action
Let me know if a PR is preferred.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions