Subject: Re: bug#66431: [PATCH] Fix reset treesit--explorer-last-node when explorer buffer was killed

From: Yuan Fu <[email-masked]>
Date: Sat, 21 Oct 2023 11:33:20 -0700

> On Oct 20, 2023, at 2:22 PM, nvp <[email-masked]> wrote:
> 
> That fixes the problem!
> 
> However, the reason I initially put the reset inside the `(unless (buffer-live-p treesit--explorer-buffer) ...)`
> in `treesit-explore-mode` was b/c it looked like there was an optimization happening in 
> `treesit--explorer-refresh` where it does this check 
> 
>            ;; If we didn't edit the buffer nor change the top-level
>            ;; node, don't redraw the whole syntax tree.
>            (highlight-only (treesit-node-eq
>                             top-level treesit--explorer-last-node))
> 
> I don't know if that is something you'd want to keep, but just pointing it out in case.  I think
> the initial patch works as well, but still allows that check to work when the explorer buffer hasn't 
> been killed.

Oh that’s fine, treesit-explore-mode always wipes everything and start from a clean slate. That optimization is for when the user moves point in the source buffer when explore-mode is on. If you’d like to send a patch that does roughly what I did in the patch I sent, I’d love to merge it. Otherwise I can fix it myself, too.

The initial patch could be a bit confusing to the readers since it sets last-node twice, and it’s not clear why.

Thanks,
Yuan