GNU bug report logs -
#66431
[PATCH] Fix reset treesit--explorer-last-node when explorer buffer was killed
Previous Next
Reported by: nvp <noah.v.peart <at> gmail.com>
Date: Tue, 10 Oct 2023 06:04:02 UTC
Severity: normal
Tags: patch
Done: Yuan Fu <casouri <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #23 received at 66431 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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.
Thankyou!
On Wed, Oct 18, 2023 at 9:36 PM Yuan Fu <casouri <at> gmail.com> wrote:
>
>
> > On Oct 14, 2023, at 9:20 PM, nvp <noah.v.peart <at> gmail.com> wrote:
> >
> > Hi,
> > The patch is supposed to reset `treesit--explorer-last-node` in the
> source buffer, just before the `(with-current-buffer
> treesit--explorer-buffer ...)`.
> > Upon trying to reproduce it now, I realized it's harder to reproduce
> than I had thought -- sorry about that.
> > I noticed the bug (if it is a bug) initially when I was adding a
> function to jump b/w source and explorer buffers, like the following:
> >
> > (defun my-treesit-explorer-jump ()
> > "Pop b/w source and explorer buffers."
> > (interactive)
> > (let ((buf
> > (cond
> > ((eq major-mode 'treesit--explorer-tree-mode)
> > (when (buffer-live-p treesit--explorer-source-buffer)
> > treesit--explorer-source-buffer))
> > (t
> > (unless (and treesit-explore-mode
> > (buffer-live-p treesit--explorer-buffer))
> > ;; *** Without the reset here, the explorer buffer doesn't
> > ;; get redrawn the first time, when
> treesit--explorer-last-node
> > ;; is non-nil in the source buffer ***
> > ;; (setq-local treesit--explorer-last-node nil)
> > (cl-letf (((symbol-function (function completing-read))
> > (lambda (&rest _) (symbol-name
> (treesit-language-at (point))))))
> > (treesit-explore-mode 1)))
> > treesit--explorer-buffer))))
> > (pop-to-buffer buf)))
> >
> > Let me give a more precise recipe to reproduce:
> > 1. From a c++-ts-mode buffer, call `treesit-explorer-mode`, select
> `cpp`. Now there should be an explorer buffer.
> > 2. Kill the associated explorer buffer.
> > 3. Now, back in the c++-ts-mode buffer, `treesit--explorer-last-node`
> should still have a value.
> > 4. From that c++-ts-mode buffer, call `my-treesit-explorer-jump`, and
> the explorer buffer should be empty, until
> > switching back to the source buffer.
> >
> > This seems to me to be caused by `treesit--explorer-post-command` not
> running until the source
> > buffer is active again.
>
> Thank you, I think I see the problem now. Could you try the below patch
> and see it fixes your problem? Also, sorry for the late reply, I meant to
> reply sooner but couldn’t find the time to figure out what exact was the
> cause :-) I was initially a bit confused since we already do set last-node
> to nil.
>
> Yuan
>
>
>
>
[Message part 2 (text/html, inline)]
This bug report was last modified 1 year and 291 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.