bug#81628: 30.2; c-ts-mode incorrect indentation for multi-line comments when using tabs (\t)

Artem Bunichev <[email protected]>
Newsgroups gmane.emacs.bugs
Message-ID <CAMNnYj=srdkwQ+qUVzhHHEmd78-FjFZHoiq143nOx43Prp43nQ@mail.gmail.com>
Hi!

I found the following bug in the c-ts-mode logic that handles indentation
and continuation for multi-line comments (I believe it must be
`c-ts-common-comment-indent-new-line`, but I'm not sure).

It can be reproduced with `emacs -Q`, assuming treesitter grammar for
c-ts-mode is installed:

0. Empty the scratch buffer.
1. M-x c-ts-mode
2. M-x whitespace-mode
   (to be able to tell \t from whitespaces)
3. M-: (setq-local c-ts-mode-indent-offset 8)
4. M-: (setq-local indent-tabs-mode nil)
5. Type something basic to get a nested structure, e.g (`|` indicates a
   cursor position, `.` indicates a whitespace, produces by TAB):
   int
   main()
   {
   ......../*|
   }
6. M-j
7. You should see:
   int
   main()
   {
   ......../*
   .........*|
   }
7.1. It works when we use whitespaces (indent-tabs-mode is nil).
8. M-: (setq-local indent-tabs-mode t)
   (Now use tabs.)
9. Roll back to step 5 (this time tabs will be used instead of
whitespaces; `\t` is a single tab character):
   int
   main()
   {
   \t/*|
   }
10. M-j
11. You should see:
   int
   main()
   {
   \t/*|
   ..*|
   }
11.1. It does not work when we use tabs.
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.