GNU bug report logs -
#59693
29.0.50; treesitter in base buffer doesn't respond to modifications in indirect buffer correctly
Previous Next
Reported by: miha <at> kamnitnik.top
Date: Tue, 29 Nov 2022 20:21:01 UTC
Severity: normal
Found in version 29.0.50
Done: Yuan Fu <casouri <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> Actually there’s a little bit of problem. When we edit the base buffer, we
> would want to update the parsers in all of its indirect buffers as well, and
> AFAICT there is no pointer from base buffer to the indirect buffer, only the
> other way around.
Background note: I consider indirect buffers an attractive nuisance
and for this reason I think we should spend as little time as possible
improving them. Instead we should encourage people to develop
alternative approaches.
I know we have a large number of bugs lurking in that area.
E.g.:
Emacs -Q
M-x clone-indirect-buffer RET
M-x fundamental-mode RET
we see that `*scratch*` has lost its font-lock highlighting even though we
changed major mode in the "other" buffer.
Now go to `*scratch*` type some text: you see that font-lock properly
updates the new code's highlighting.
Then go to `*scratch*<2>` and type some more text: you should see that
font-lock does *not* properly update the new code's highlighting in the
base buffer.
AFAICT this is the exact same bug as what you're seeing, just with
font-lock instead of tree-sitter. [ Of course, for font-lock it's worse
because font-lock uses text-properties (which are shared between the
base and the its indirect buffers) so it simply can't do its job
properly in indirect buffers. ]
This bug has been with us since indirect buffers were invented, so
it has very low priority, AFAIC.
> Then base buffer can update all indirect buffers’ parsers, and indirect
> buffer can find its base buffer and update all the parsers, including the
> base buffer’s parsers and other indirect buffers’ parsers.
Don't bother, please.
Instead, I recommend you disallow the use of tree sitter in indirect
buffers. And we should probably try and change `insdel.c` so it always
runs the `after/before-change-functions` in the base buffer (this should
fix the worst part of the problems).
Stefan
This bug report was last modified 2 years and 163 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.