mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
fix: safe check string before inserting when autocomplete
also, enables two consecutive spaces to exit autocomplete
This commit is contained in:
@@ -281,7 +281,6 @@
|
||||
(p/let [_ (draw/create-draw-with-default-content path)]
|
||||
(println "draw file created, " path))
|
||||
text)) "Draw a graph with Excalidraw"]
|
||||
|
||||
["Embed HTML " (->inline "html")]
|
||||
|
||||
["Embed Video URL" [[:editor/input "{{video }}" {:last-pattern (state/get-editor-command-trigger)
|
||||
@@ -372,12 +371,13 @@
|
||||
(str prefix postfix))
|
||||
new-pos (- (count prefix)
|
||||
(or backward-pos 0))]
|
||||
(state/set-block-content-and-last-pos! id new-value new-pos)
|
||||
(cursor/move-cursor-to input
|
||||
(if (and (or backward-pos forward-pos)
|
||||
(not= end-pattern "]]"))
|
||||
new-pos
|
||||
(inc new-pos))))))
|
||||
(when-not (string/blank? new-value)
|
||||
(state/set-block-content-and-last-pos! id new-value new-pos)
|
||||
(cursor/move-cursor-to input
|
||||
(if (and (or backward-pos forward-pos)
|
||||
(not= end-pattern "]]"))
|
||||
new-pos
|
||||
(inc new-pos)))))))
|
||||
|
||||
(defn simple-insert!
|
||||
[id value
|
||||
|
||||
@@ -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?))
|
||||
|
||||
Reference in New Issue
Block a user