Browse Source

fix(editor): wrong last pos when hashtag pressed

Andelf 4 years ago
parent
commit
c6d6871684
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/main/frontend/handler/editor.cljs

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

@@ -2977,7 +2977,9 @@
         hashtag?
         (do
           (commands/handle-step [:editor/search-page-hashtag])
-          (state/set-last-pos! (cursor/pos input))
+          (if (= key "#")
+            (state/set-last-pos! (inc (cursor/pos input))) ;; In keydown handler, the `#` is not inserted yet.
+            (state/set-last-pos! (cursor/pos input)))
           (reset! commands/*slash-caret-pos (cursor/get-caret-pos input)))
 
         (let [sym "$"]