Browse Source

chore: get rid of dec & inc

Yukun Guo 5 years ago
parent
commit
5f8915b304
2 changed files with 3 additions and 3 deletions
  1. 2 2
      src/main/frontend/diff.cljs
  2. 1 1
      src/main/frontend/handler/editor.cljs

+ 2 - 2
src/main/frontend/diff.cljs

@@ -22,7 +22,7 @@
             [h2 & r2] t2]
         (cond
           (or (empty? t1) (empty? t2))
-          (dec i1)
+          i1
 
           (= h1 h2)
           (recur r1 r2 (inc i1) (inc i2))
@@ -34,4 +34,4 @@
           (recur r1 t2 (inc i1) i2))))
       (catch js/Error e
         (log/error :diff/find-position {:error e})
-        (dec (count markup)))))
+        (count markup))))

+ 1 - 1
src/main/frontend/handler/editor.cljs

@@ -145,7 +145,7 @@
    (when-let [node (gdom/getElement (str id))]
      (when-let [cursor-range (state/get-cursor-range)]
        (when-let [range (string/trim cursor-range)]
-         (let [pos (inc (diff/find-position markup range))]
+         (let [pos (diff/find-position markup range)]
            (util/set-caret-pos! node pos)))))))
 
 (defn block-content-join-newlines