Skip to content

org-ql-find: intermittent freezing with vertico #350

@anpandey

Description

@anpandey

When using 0.7.1-pre's org-ql-find with vertico, I sometimes get the following message:

Error in post-command-hook (vertico--exhibit): (user-error "Before first headline at position 13 in buffer  *Minibuf-1*")

follwed by completion freezing up until it's manually cancelled. There doesn't appear to be a specific query causing it, and the only semi-reliable way I was to reproduce this was by changing the query randomly (and quickly) until I got the error. I was also able to reproduce this in a minimal (4-headline) file, manual debug trace below (it seems like a nil marker causes org-back-to-heading to be called within the minibuffer):

Debugger entered: nil
  (or (re-search-backward (concat "^\\(?:" outline-regexp "\\)") nil t) (debug) (user-error "Before first headline at position %d in buffer %s" (point) (current-buffer)))
  (while (not found) (or (re-search-backward (concat "^\\(?:" outline-regexp "\\)") nil t) (debug) (user-error "Before first headline at position %d in buffer %s" (point) (current-buffer))) (if (and (featurep 'org-inlinetask) (fboundp 'org-inlinetask-end-p) (org-inlinetask-end-p)) (org-inlinetask-goto-beginning) (setq found (and (or invisible-ok (not (org-fold-folded-p))) (point)))))
  (save-excursion (if (and (featurep 'org-inlinetask) (fboundp 'org-inlinetask-end-p) (org-inlinetask-end-p)) (progn (goto-char (line-beginning-position)))) (while (not found) (or (re-search-backward (concat "^\\(?:" outline-regexp "\\)") nil t) (debug) (user-error "Before first headline at position %d in buffer %s" (point) (current-buffer))) (if (and (featurep 'org-inlinetask) (fboundp 'org-inlinetask-end-p) (org-inlinetask-end-p)) (org-inlinetask-goto-beginning) (setq found (and (or invisible-ok (not (org-fold-folded-p))) (point))))))
  (let (found) (save-excursion (if (and (featurep 'org-inlinetask) (fboundp 'org-inlinetask-end-p) (org-inlinetask-end-p)) (progn (goto-char (line-beginning-position)))) (while (not found) (or (re-search-backward (concat "^\\(?:" outline-regexp "\\)") nil t) (debug) (user-error "Before first headline at position %d in buffer %s" (point) (current-buffer))) (if (and (featurep 'org-inlinetask) (fboundp 'org-inlinetask-end-p) (org-inlinetask-end-p)) (org-inlinetask-goto-beginning) (setq found (and (or invisible-ok (not ...)) (point)))))) (goto-char found) found)
  (if (org-element--cache-active-p) (let ((heading (org-element-lineage (org-element-at-point) '(headline inlinetask) 'include-self))) (if heading (progn (goto-char (org-element-property :begin heading)))) (while (and (not invisible-ok) heading (org-fold-folded-p)) (goto-char (org-fold-core-previous-visibility-change)) (setq heading (org-element-lineage (org-element-at-point) '(headline inlinetask) 'include-self)) (if heading (progn (goto-char (org-element-property :begin heading))))) (if heading nil (debug) (user-error "Before first headline at position %d in buffer %s" (point) (current-buffer))) (point)) (let (found) (save-excursion (if (and (featurep 'org-inlinetask) (fboundp 'org-inlinetask-end-p) (org-inlinetask-end-p)) (progn (goto-char (line-beginning-position)))) (while (not found) (or (re-search-backward (concat "^\\(?:" outline-regexp "\\)") nil t) (debug) (user-error "Before first headline at position %d in buffer %s" (point) (current-buffer))) (if (and (featurep 'org-inlinetask) (fboundp 'org-inlinetask-end-p) (org-inlinetask-end-p)) (org-inlinetask-goto-beginning) (setq found (and (or invisible-ok ...) (point)))))) (goto-char found) found))
  (or (and (org-at-heading-p (not invisible-ok)) (not (and (featurep 'org-inlinetask) (fboundp 'org-inlinetask-end-p) (org-inlinetask-end-p)))) (if (org-element--cache-active-p) (let ((heading (org-element-lineage (org-element-at-point) '(headline inlinetask) 'include-self))) (if heading (progn (goto-char (org-element-property :begin heading)))) (while (and (not invisible-ok) heading (org-fold-folded-p)) (goto-char (org-fold-core-previous-visibility-change)) (setq heading (org-element-lineage (org-element-at-point) '(headline inlinetask) 'include-self)) (if heading (progn (goto-char (org-element-property :begin heading))))) (if heading nil (debug) (user-error "Before first headline at position %d in buffer %s" (point) (current-buffer))) (point)) (let (found) (save-excursion (if (and (featurep 'org-inlinetask) (fboundp 'org-inlinetask-end-p) (org-inlinetask-end-p)) (progn (goto-char (line-beginning-position)))) (while (not found) (or (re-search-backward (concat "^\\(?:" outline-regexp "\\)") nil t) (debug) (user-error "Before first headline at position %d in buffer %s" (point) (current-buffer))) (if (and (featurep ...) (fboundp ...) (org-inlinetask-end-p)) (org-inlinetask-goto-beginning) (setq found (and ... ...))))) (goto-char found) found)))
  org-back-to-heading(t)
  org-up-heading-safe()
  org-get-outline-path(nil t)
  #f(compiled-function (marker) #<bytecode 0x93f5ad3be78f3fa>)(nil)
  #f(compiled-function (completions) #<bytecode 0x17cd8a122f0e5d5>)((#("indented headline" 0 17 (line-prefix #("**" 0 2 (face org-indent)) wrap-prefix #("***** " 0 6 (face org-indent)) fontified t face org-level-3)) #("This is another test, I don't know" 0 34 (line-prefix "" wrap-prefix #("* " 0 2 (face org-indent)) fontified t face org-level-1))))
  vertico--affixate((#("indented headline" 0 17 (line-prefix #("**" 0 2 (face org-indent)) wrap-prefix #("***** " 0 6 (face org-indent)) fontified t face org-level-3)) #("This is another test, I don't know" 0 34 (line-prefix "" wrap-prefix #("* " 0 2 (face org-indent)) fontified t face org-level-1))))
  vertico--arrange-candidates()
  vertico--exhibit()
  #<subr completing-read-default>("Find entry: " #f(compiled-function (input pred flag) #<bytecode 0x5410b96d6237eee>) nil t nil nil nil nil)
  apply((#<subr completing-read-default> "Find entry: " #f(compiled-function (input pred flag) #<bytecode 0x5410b96d6237eee>) nil t nil nil nil nil))
  vertico--advice(#<subr completing-read-default> "Find entry: " #f(compiled-function (input pred flag) #<bytecode 0x5410b96d6237eee>) nil t nil nil nil nil)
  apply(vertico--advice #<subr completing-read-default> ("Find entry: " #f(compiled-function (input pred flag) #<bytecode 0x5410b96d6237eee>) nil t nil nil nil nil))
  completing-read-default("Find entry: " #f(compiled-function (input pred flag) #<bytecode 0x5410b96d6237eee>) nil t nil nil nil nil)
  org-ql-completing-read(#<buffer testfile.org> :query-prefix nil :query-filter nil :prompt "Find entry: ")
  org-ql-find(#<buffer testfile.org>)

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions