Alexander-Miller / treemacs

GNU General Public License v3.0
2.05k stars 151 forks source link

Variadic nodes can't be refreshed if they have no children #1065

Closed kurnevsky closed 8 months ago

kurnevsky commented 9 months ago

It seems there is no way to refresh treemacs variadic node in case they don't have nodes anymore. We need this for metals treeview.

This one works:

(with-current-buffer (get-buffer-create "test")
  (defun test-children ()
    (list 1))

  (treemacs-define-leaf-node-type test-leaf
    :icon " "
    :label "test"
    :key item)

  (treemacs-define-variadic-entry-node-type test-root
    :key 'test-root
    :children (test-children)
    :child-type 'test-leaf)

  (treemacs-initialize test-root)

  (treemacs-update-node '(test-root) t))

This one doesn't:

(with-current-buffer (get-buffer-create "test")
  (defun test-children ())

  (treemacs-define-leaf-node-type test-leaf
    :icon " "
    :label "test"
    :key item)

  (treemacs-define-variadic-entry-node-type test-root
    :key 'test-root
    :children (test-children)
    :child-type 'test-leaf)

  (treemacs-initialize test-root)

  (treemacs-update-node '(test-root) t))

Note that initially it's displayed correctly, the error happens only in treemacs-update-node.

Alexander-Miller commented 8 months ago

Should be fixed now, at least your example doesn't fail for me.