Alexander-Miller / treemacs

GNU General Public License v3.0
2.12k stars 156 forks source link

`treemacs--async-update-part-complete` fails with `(wrong-type-argument number-or-marker-p nil)` #1106

Open drskalman opened 6 months ago

drskalman commented 6 months ago

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil) =(0 nil) (if (= 0 count) (progn (let ((it (buffer-live-p buffer))) (if it (progn (save-current-buffer (set-buffer buffer) (let (buffer-read-only) (treemacs-update-node top-path) (let* ... ...)))))))) (let* ((count (let* ((v treemacs--async-update-count) (v top-path)) (ht-set! v v (- (ht-get v v) 1))))) (if (= 0 count) (progn (let ((it (buffer-live-p buffer))) (if it (progn (save-current-buffer (set-buffer buffer) (let ... ... ...)))))))) treemacs--async-update-part-complete((lsp-treemacs-generic-root "foo") (lsp-treemacs-generic-root "foo") nil #<buffer *dap-ui-locals*>) (closure ((item-path lsp-treemacs-generic-root "foo") (buffer . #<buffer *dap-ui-locals*>) (path lsp-treemacs-generic-root "foo")) (items) (treemacs--async-update-part-complete path item-path items buffer))(nil) funcall((closure ((item-path lsp-treemacs-generic-root "foo") (buffer . #<buffer *dap-ui-locals*>) (path lsp-treemacs-generic-root "foo")) (items) (treemacs--async-update-part-complete path item-path items buffer)) nil) (cond ((functionp children) (funcall callback (lsp-treemacs-filter-if-needed (funcall children item)))) (children-async (let* ((buffer (current-buffer))) (funcall children-async item #'(lambda (result) (if (buffer-live-p ...) (progn ...)))))) (t (funcall callback (lsp-treemacs-filter-if-needed children)))) (let* ((item input0) (children (plist-get item :children)) (children-async (plist-get item :children-async))) (cond ((functionp children) (funcall callback (lsp-treemacs-filter-if-needed (funcall children item)))) (children-async (let* ((buffer (current-buffer))) (funcall children-async item #'(lambda (result) (if ... ...))))) (t (funcall callback (lsp-treemacs-filter-if-needed children))))) (let ((input0 item)) (let* ((item input0) (children (plist-get item :children)) (children-async (plist-get item :children-async))) (cond ((functionp children) (funcall callback (lsp-treemacs-filter-if-needed (funcall children item)))) (children-async (let* ((buffer (current-buffer))) (funcall children-async item #'(lambda ... ...)))) (t (funcall callback (lsp-treemacs-filter-if-needed children)))))) (closure (t) (&optional btn item callback) (ignore btn item callback) (let ((input0 item)) (let* ((item input0) (children (plist-get item :children)) (children-async (plist-get item :children-async))) (cond ((functionp children) (funcall callback (lsp-treemacs-filter-if-needed ...))) (children-async (let* (...) (funcall children-async item ...))) (t (funcall callback (lsp-treemacs-filter-if-needed children)))))))(#<marker (moves after insertion) at 15 in *dap-ui-locals*> (:label "Nothing to display..." :key "foo" :icon :empty) (closure ((item-path lsp-treemacs-generic-root "foo") (buffer . #<buffer *dap-ui-locals*>) (path lsp-treemacs-generic-root "foo")) (items) (treemacs--async-update-part-complete path item-path items buffer))) funcall((closure (t) (&optional btn item callback) (ignore btn item callback) (let ((input0 item)) (let* ((item input0) (children (plist-get item :children)) (children-async (plist-get item :children-async))) (cond ((functionp children) (funcall callback (lsp-treemacs-filter-if-needed ...))) (children-async (let* (...) (funcall children-async item ...))) (t (funcall callback (lsp-treemacs-filter-if-needed children))))))) #<marker (moves after insertion) at 15 in *dap-ui-locals*> (:label "Nothing to display..." :key "foo" :icon :empty) (closure ((item-path lsp-treemacs-generic-root "foo") (buffer . #<buffer *dap-ui-locals*>) (path lsp-treemacs-generic-root "foo")) (items) (treemacs--async-update-part-complete path item-path items buffer))) (let* ((item-path (car item)) (ext (cdr item)) (btn (treemacs-find-node item-path)) (item (get-text-property btn :item)) (children-fn (progn (or (progn (and (memq ... cl-struct-treemacs-extension-tags) t)) (signal 'wrong-type-argument (list 'treemacs-extension ext))) (aref ext 6)))) (funcall children-fn btn item #'(lambda (items) (treemacs--async-update-part-complete path item-path items buffer)))) (let ((item (car tail))) (let* ((item-path (car item)) (ext (cdr item)) (btn (treemacs-find-node item-path)) (item (get-text-property btn :item)) (children-fn (progn (or (progn (and ... t)) (signal 'wrong-type-argument (list ... ext))) (aref ext 6)))) (funcall children-fn btn item #'(lambda (items) (treemacs--async-update-part-complete path item-path items buffer)))) (setq tail (cdr tail))) (while tail (let ((item (car tail))) (let* ((item-path (car item)) (ext (cdr item)) (btn (treemacs-find-node item-path)) (item (get-text-property btn :item)) (children-fn (progn (or (progn ...) (signal ... ...)) (aref ext 6)))) (funcall children-fn btn item #'(lambda (items) (treemacs--async-update-part-complete path item-path items buffer)))) (setq tail (cdr tail)))) (let ((tail items-to-update)) (while tail (let ((item (car tail))) (let* ((item-path (car item)) (ext (cdr item)) (btn (treemacs-find-node item-path)) (item (get-text-property btn :item)) (children-fn (progn (or ... ...) (aref ext 6)))) (funcall children-fn btn item #'(lambda (items) (treemacs--async-update-part-complete path item-path items buffer)))) (setq tail (cdr tail))))) (let* ((items-to-update (treemacs--get-async-update-items path))) (ht-set! treemacs--async-update-count path (length items-to-update)) (let ((tail items-to-update)) (while tail (let ((item (car tail))) (let* ((item-path (car item)) (ext (cdr item)) (btn (treemacs-find-node item-path)) (item (get-text-property btn :item)) (children-fn (progn ... ...))) (funcall children-fn btn item #'(lambda ... ...))) (setq tail (cdr tail)))))) treemacs-update-async-node((lsp-treemacs-generic-root "foo") #<buffer *dap-ui-locals*>)

I fixed it with this:

-   (when (= 0 count)
+   (when (or (not count) (= 0 count))
Alexander-Miller commented 6 months ago

The fix would work, but really it's a thing that should not have happened in the first place, though it's been a while since I wrote that code. Is it possible to reproduce this problem?

stale[bot] commented 4 months ago

This issue has been automatically marked as stale because it has not had recent activity (this bot only works as a reminder, it will not close issues).