浏览代码

fix: parent ordering in page ref completion

Likely affected other features
Gabriel Horner 1 年之前
父节点
当前提交
a3ead39156
共有 2 个文件被更改,包括 25 次插入25 次删除
  1. 1 1
      deps/db/src/logseq/db.cljs
  2. 24 24
      src/main/frontend/components/editor.cljs

+ 1 - 1
deps/db/src/logseq/db.cljs

@@ -627,7 +627,7 @@
                         (remove (fn [e] (= :logseq.class/Root (:db/ident e)))))]
       (string/join
        ns-util/parent-char
-       (map :block/title (conj parents' entity))))
+       (map :block/title (conj (vec parents') entity))))
     (:block/title entity)))
 
 (defn get-classes-parents

+ 24 - 24
src/main/frontend/components/editor.cljs

@@ -146,32 +146,32 @@
                                       (editor-handler/<get-matched-blocks q {:nlp-pages? true}))]
                        (set-matched-pages! result))))]
     (rum/use-effect! search-f [(mixins/use-debounce 50 q)])
-    (let [matched-pages (if (string/blank? q)
-                          (if db-tag?
-                            (db-model/get-all-classes (state/get-current-repo) {:except-root-class? true})
-                            (->> (map (fn [title] {:block/title title
-                                                   :nlp-date? true})
-                                      date/nlp-pages)
-                                 (take 10)))
-                          ;; reorder, shortest and starts-with first.
-                          (let [matched-pages-with-new-page
-                                (fn [partial-matched-pages]
-                                  (if (or (db/page-exists? q (if db-tag? "class" "page"))
-                                          (and db-tag? (some ldb/class? (:block/_alias (db/get-page q)))))
-                                    partial-matched-pages
-                                    (if db-tag?
-                                      (concat [{:block/title (str (t :new-tag) " " q)}]
-                                              partial-matched-pages)
-                                      (cons {:block/title (str (t :new-page) " " q)}
-                                            partial-matched-pages))))]
-                            (if (and (seq matched-pages)
-                                     (gstring/caseInsensitiveStartsWith (:block/title (first matched-pages)) q))
-                              (cons (first matched-pages)
-                                    (matched-pages-with-new-page (rest matched-pages)))
-                              (matched-pages-with-new-page matched-pages))))]
+    (let [matched-pages' (if (string/blank? q)
+                           (if db-tag?
+                             (db-model/get-all-classes (state/get-current-repo) {:except-root-class? true})
+                             (->> (map (fn [title] {:block/title title
+                                                    :nlp-date? true})
+                                       date/nlp-pages)
+                                  (take 10)))
+                           ;; reorder, shortest and starts-with first.
+                           (let [matched-pages-with-new-page
+                                 (fn [partial-matched-pages]
+                                   (if (or (db/page-exists? q (if db-tag? "class" "page"))
+                                           (and db-tag? (some ldb/class? (:block/_alias (db/get-page q)))))
+                                     partial-matched-pages
+                                     (if db-tag?
+                                       (concat [{:block/title (str (t :new-tag) " " q)}]
+                                               partial-matched-pages)
+                                       (cons {:block/title (str (t :new-page) " " q)}
+                                             partial-matched-pages))))]
+                             (if (and (seq matched-pages)
+                                      (gstring/caseInsensitiveStartsWith (:block/title (first matched-pages)) q))
+                               (cons (first matched-pages)
+                                     (matched-pages-with-new-page (rest matched-pages)))
+                               (matched-pages-with-new-page matched-pages))))]
       [:<>
        (ui/auto-complete
-        matched-pages
+        matched-pages'
         {:on-chosen   (page-on-chosen-handler embed? input id q pos format)
          :on-enter    (fn []
                         (page-handler/page-not-exists-handler input id q current-pos))