Bypass narrowing when calculating inherited tags in narrowed buffer

Otherwise, children queries may generate wrong tags and pollute tag cache.
This commit is contained in:
Ihor Radchenko 2021-04-05 21:11:46 +08:00
parent 9b30c4139b
commit 3e6818d819
No known key found for this signature in database
GPG key ID: 6470762A7DA11D8B

View file

@ -565,25 +565,26 @@ Returns cons (INHERITED-TAGS . LOCAL-TAGS)."
'org-ql-nil)) 'org-ql-nil))
(inherited-tags (or (when org-use-tag-inheritance (inherited-tags (or (when org-use-tag-inheritance
(save-excursion (save-excursion
(if (org-up-heading-safe) (org-with-wide-buffer
;; Return parent heading's tags. (if (org-up-heading-safe)
(-let* (((inherited local) (org-ql--tags-at (point))) ;; Return parent heading's tags.
(tags (when (or inherited local) (-let* (((inherited local) (org-ql--tags-at (point)))
(cond ((and (listp inherited) (tags (when (or inherited local)
(listp local)) (cond ((and (listp inherited)
(->> (append inherited local) (listp local))
-non-nil -uniq)) (->> (append inherited local)
((listp inherited) inherited) -non-nil -uniq))
((listp local) local))))) ((listp inherited) inherited)
(cl-typecase org-use-tag-inheritance ((listp local) local)))))
(list (setf tags (-intersection tags org-use-tag-inheritance))) (cl-typecase org-use-tag-inheritance
(string (setf tags (--select (string-match org-use-tag-inheritance it) (list (setf tags (-intersection tags org-use-tag-inheritance)))
tags)))) (string (setf tags (--select (string-match org-use-tag-inheritance it)
(pcase org-tags-exclude-from-inheritance tags))))
('nil tags) (pcase org-tags-exclude-from-inheritance
(_ (-difference tags org-tags-exclude-from-inheritance)))) ('nil tags)
;; Top-level heading: use file tags. (_ (-difference tags org-tags-exclude-from-inheritance))))
org-file-tags))) ;; Top-level heading: use file tags.
org-file-tags))))
'org-ql-nil)) 'org-ql-nil))
(all-tags (list inherited-tags local-tags))) (all-tags (list inherited-tags local-tags)))
;; Check caches again, because they may have been set now. ;; Check caches again, because they may have been set now.