bug#81587: c-ts-mode narrowing disturbs the indirect buffer

Eli Zaretskii <[email protected]>
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
> From: Tomas Nordin <[email protected]>
> Date: Sun, 09 Aug 2026 10:08:13 +0000
> 
> Hello
> 
> Using c-ts-mode, cloning the buffer, narrowing the direct buffer, doing
> some navigation in the indirect buffer, seem problematic. Like this for
> example:
> 
> $ emacs -Q lib-src/asset-directory-tool.c
> 
> M-x c-ts-mode
> C-s main_1 RET
> C-x 4 c
> C-x o
> C-x n d
> C-x o
> 
> We should now be in the indirect buffer after having narrowed the
> main_1() function in the direct buffer.
> 
> Do some C-M-e and C-M-a and shortly observe
> 
> Error running timer ‘show-paren-function’: (args-out-of-range 3271)
> 
> If I skip the 'M-x c-ts-mode' step the problem is not reproduced.

The doc string of treesit-parser-create says:

  If that buffer is an indirect buffer, its base buffer is used instead.
  That is, indirect buffers use their base buffer's parsers.  Lisp
  programs should widen as necessary should they want to use a parser in
  an indirect buffer.

Yuan, any comments or suggestions?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.