fix(editor): page search autocompletion with square brackets mixed

Fix #4178
This commit is contained in:
Andelf
2022-02-10 12:02:22 +08:00
committed by Tienson Qin
parent b637c2d85a
commit fef8c3970b

View File

@@ -660,7 +660,7 @@
(fn [chosen _click?]
(state/set-editor-show-page-search! false)
(let [wrapped? (= "[[" (util/safe-subs edit-content (- pos 2) pos))
chosen (if (string/starts-with? chosen "New page: ")
chosen (if (string/starts-with? chosen "New page: ") ;; FIXME: What if a page named "New page: XXX"?
(subs chosen 10)
chosen)
chosen (if (and (util/safe-re-find #"\s+" chosen) (not wrapped?))
@@ -677,7 +677,7 @@
(str "#" (when wrapped? "[[") chosen)
format
{:last-pattern last-pattern
:end-pattern "]]"
:end-pattern (when wrapped? "]]")
:forward-pos forward-pos})))
(fn [chosen _click?]
(state/set-editor-show-page-search! false)