Skip to content

Commit e46e78a

Browse files
committed
Remove pnodes
1 parent 55bc7b6 commit e46e78a

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/rewrite_clj/zip/zip.clj

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,18 @@
6868
{:node c
6969
:position [row (+ col (node/leader-length node))]
7070
:parent loc
71-
:path {:l []
72-
:pnodes (if path (conj (:pnodes path) node) [node])
73-
:ppath path
71+
:path {:l []
72+
:ppath path
7473
:r cnext}}))))
7574

7675
(defn up
7776
"Returns the loc of the parent of the node at this loc, or nil if at
7877
the top"
7978
[loc]
80-
(let [{:keys [node parent position] {:keys [l ppath pnodes r changed?]} :path} loc]
79+
(let [{:keys [node parent position] {:keys [l ppath r changed?]} :path} loc]
8180
(when parent
8281
(if changed?
83-
{:node (make-node loc (peek pnodes) (concat l (cons node r)))
82+
{:node (make-node loc (:node parent) (concat l (cons node r)))
8483
:path (and ppath (assoc ppath :changed? true))
8584
:parent (:parent parent)
8685
:position position}
@@ -219,7 +218,7 @@
219218
"Removes the node at loc, returning the loc that would have preceded
220219
it in a depth-first walk."
221220
[loc]
222-
(let [{:keys [node parent position] {:keys [l ppath pnodes r] :as path} :path} loc]
221+
(let [{:keys [node parent position] {:keys [l ppath r] :as path} :path} loc]
223222
(if (nil? path)
224223
(throw (new Exception "Remove at top"))
225224
(if (pos? (count l))
@@ -230,7 +229,7 @@
230229
(if-let [child (and (branch? loc) (down loc))]
231230
(recur (rightmost child))
232231
loc))
233-
{:node (make-node loc (peek pnodes) r)
232+
{:node (make-node loc (:node parent) r)
234233
:path (and ppath (assoc ppath :changed? true))
235234
:parent (:parent parent)
236235
:position position}))))

0 commit comments

Comments
 (0)