Skip to content

Commit af72aef

Browse files
committed
Fix handling of newlines
1 parent 089b25a commit af72aef

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/rewrite_clj/node/protocols.clj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,12 @@
144144
(->> s
145145
reverse
146146
(take-while (complement (partial = \newline)))
147-
count))]
147+
count
148+
inc))]
148149
[rows cols]))))
149150

150151
(defn ^:no-doc +extent
151152
[[row col] [row-extent col-extent]]
152153
[(+ row row-extent)
153154
(cond-> col-extent (zero? row-extent) (+ col))])
155+

test/rewrite_clj/zip/zip_test.clj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121

2222
(tabular
2323
(fact "z/right tracks position correctly"
24-
(let [root (base/of-string "[hello world]")
25-
zloc (nth (iterate z/right (z/down root)) ?n)]
24+
(let [root (base/of-string "[hello \nworld]")
25+
zloc (nth (iterate z/next root) ?n)]
2626
(z/position zloc) => ?pos))
2727
?n ?pos
28-
0 [1 2]
29-
1 [1 7]
30-
2 [1 8])
28+
1 [1 2]
29+
2 [1 7]
30+
3 [1 8]
31+
4 [2 1])
3132

3233
(fact "z/rightmost tracks position correctly"
3334
(let [root (base/of-string "[hello world]")]

0 commit comments

Comments
 (0)