Improve backtick autopairing (#6496)

* If you type a backtick and then some letters and then another backtick, the last backtick should close the first one and not spawn another autopair
This commit is contained in:
Viktor Moros
2022-08-26 21:32:46 -07:00
committed by GitHub
parent b47826d69d
commit f5824322b3
2 changed files with 10 additions and 4 deletions

View File

@@ -2720,9 +2720,15 @@
(do (util/stop e)
(autopair input-id "(" format nil))
;; If you type `xyz`, the last backtick should close the first and not add another autopair
;; If you type several backticks in a row, each one should autopair to accommodate multiline code (```)
(contains? (set (keys autopair-map)) key)
(do (util/stop e)
(autopair input-id key format nil))
(let [curr (get-current-input-char input)
prev (util/nth-safe value (dec pos))]
(util/stop e)
(if (and (= key "`") (= "`" curr) (not= "`" prev))
(cursor/move-cursor-forward input)
(autopair input-id key format nil)))
(and hashtag? (or (zero? pos) (re-matches #"\s" (get value (dec pos)))))
(do