fix: safe check string before inserting when autocomplete

also, enables two consecutive spaces to exit autocomplete
This commit is contained in:
Tienson Qin
2022-07-05 21:46:25 +08:00
parent 7172784504
commit 7b92360889
2 changed files with 12 additions and 7 deletions

View File

@@ -2809,6 +2809,11 @@
(reset! commands/*angle-bracket-caret-pos (cursor/get-caret-pos input))
(reset! commands/*show-block-commands true))
;; Exit autocomplete if user inputs two consecutive spaces
(and @*show-commands
(= c (util/nth-safe value (dec (dec current-pos))) " "))
(reset! *show-commands false)
(and (= c " ")
(or (= (util/nth-safe value (dec (dec current-pos))) "#")
(not (state/get-editor-show-page-search?))