Skip to content

Commit ff195b9

Browse files
committed
z/insert-right doesn't change the current position
1 parent 9c03573 commit ff195b9

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/rewrite_clj/zip/zip.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
"Inserts the item as the right sibling of the node at this loc,
155155
without moving"
156156
[loc item]
157-
(let [{:keys [node parent right]} loc]
157+
(let [{:keys [parent right]} loc]
158158
(if-not parent
159159
(throw (new Exception "Insert at top"))
160160
(assoc loc

test/rewrite_clj/zip/zip_test.clj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,9 @@
7676
z/down
7777
(z/replace 'x)
7878
z/position) => [1 2])
79+
80+
(fact "z/insert-right doesn't change the current position"
81+
(-> (base/of-string "[hello world]")
82+
z/down
83+
(z/insert-right 'x)
84+
z/position) => [1 2])

0 commit comments

Comments
 (0)