fix: tag completion showing 2 entries for an existing tag

including 'New tag'. Regression from e92ea7a771
This commit is contained in:
Gabriel Horner
2025-06-24 14:53:34 -04:00
parent 9f924dd587
commit b940138a39

View File

@@ -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))))