[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#59630: 29.0.50; treesitter-buffer-root-node doesn't change when chan
From: |
Yuan Fu |
Subject: |
bug#59630: 29.0.50; treesitter-buffer-root-node doesn't change when changing buffer restriction |
Date: |
Sun, 27 Nov 2022 14:40:41 -0800 |
> On Nov 27, 2022, at 4:49 AM, miha--- via Bug reports for GNU Emacs, the Swiss
> army knife of text editors <bug-gnu-emacs@gnu.org> wrote:
>
> Treesitter doesn't seem to change its parse tree when changing
> restriction. It gets it correct the first time when we query the root
> node, but then, after changing restriction, it doesn't seem to get
> updated.
>
> The following is an M-x ielm session to demonstrate the problem
>
> ELISP> (set-buffer (get-buffer-create "test"))
> ELISP> (insert "echo '123'")
> ELISP> (narrow-to-region 1 4)
> ELISP> (buffer-string)
> "echo"
> ELISP> (treesit-buffer-root-node 'bash)
> #<treesit-node
> (program)
> in 1-4> ;; This is expected
>
> ELISP> (widen)
> ELISP> (treesit-buffer-root-node 'bash)
> #<treesit-node
> (program)
> in 1-4> ;; <---- This is not expected, the root node should span 1-9
>
> ELISP> (buffer-string)
> "echo '123'"
Thanks. We didn’t edit the buffer after widening, so tree-sitter didn’t reparse
and used the old tree, which sees the narrowed buffer. Eli, what would be a
good and reliable way to know that narrowing has changed? I see
current_buffer->clip_changed set to 1 in narrow-to-region and widen, but when
are they set to 0?
Yuan