浏览代码

fix: tag completion showing 2 entries for an existing tag

including 'New tag'. Regression from e92ea7a771322d875791b6a40a8c9b82895912c7
Gabriel Horner 4 月之前
父节点
当前提交
b940138a39
共有 1 个文件被更改,包括 11 次插入9 次删除
  1. 11 9
      src/main/frontend/components/editor.cljs

+ 11 - 9
src/main/frontend/components/editor.cljs

@@ -136,18 +136,20 @@
 
 (defn- matched-pages-with-new-page [partial-matched-pages db-tag? q]
   (if (or
-       (if db-tag?
-         (let [entity (db/get-page q)]
-           (and (ldb/internal-page? entity) (= (:block/title entity) q)))
-         ;; Page existence here should be the same as entity-util/page?.
-         ;; Don't show 'New page' if a page has any of these tags
-         (db/page-exists? q db-class/page-classes))
-
+       (db/page-exists? q (if db-tag?
+                            #{:logseq.class/Tag}
+                            ;; Page existence here should be the same as entity-util/page?.
+                            ;; Don't show 'New page' if a page has any of these tags
+                            db-class/page-classes))
        (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)
+      (concat
+       ;; Don't show 'New tag' for an internal page because it already shows 'Convert ...'
+       (when-not (let [entity (db/get-page q)]
+                   (and (ldb/internal-page? entity) (= (:block/title entity) q)))
+         [{:block/title (str (t :new-tag) " " q)}])
+       partial-matched-pages)
       (cons {:block/title (str (t :new-page) " " q)}
             partial-matched-pages))))