GNU bug report logs -
#61923
30.0.50; go-ts-mode, multiline raw-string-literal wrong indentation
Previous Next
Reported by: Gleb Zakharov <snyssfx <at> posteo.net>
Date: Thu, 2 Mar 2023 22:21:01 UTC
Severity: normal
Found in version 30.0.50
Fixed in version 29.1
Done: Dmitry Gutov <dmitry <at> gutov.dev>
Bug is archived. No further changes may be made.
Full log
Message #11 received at 61923 <at> debbugs.gnu.org (full text, mbox):
[Please always use Reply All to keep the bug address on the CC list.]
> From: Gleb Zakharov <snyssfx <at> posteo.net>
> Date: Fri, 03 Mar 2023 11:26:32 +0000
>
> Hi Eli,
> Thanks for the quick reply.
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
> > Tweaking the language indentation
> > rules to cater for these quite specialized use cases is not TRT, IMO,
> > because it is likely to contradict what the majority of language users
> > want and expect.
>
> I'm not sure if you meant that the special case involves embedding other
> languages or simply using multi-line strings.
The latter. AFAIU, you suggested to change how multi-line strings are
indented because of the use case of embedding other languages there.
> While raw strings in Go can be used for various purposes,
> including the code of other languages, they can also be used for
> arbitrary text. The issue I'm facing is that when tabs are added by
> tree-sitter indentation, they become a part of the string, which can
> affect the program, for example if we want to compare strings with each
> other.
>
> Consider this example:
> ```
> // (require 'treesit)
> // (require 'go-ts-mode)
> // (setq treesit-extra-load-path '("/home/snyssfx/.guix-home/profile/lib/tree-sitter"))
> // (go-ts-mode)
>
> func a() {
> _ = `
> Lorem ipsum dolor sit amet,
> consectetur adipiscing elit,
> sed do eiusmod tempor incididunt ut
> labore et dolore magna aliqua.
> `
> }
> ```
>
> If I call M-q or make a change somewhere in the string, part of the text inside
> the string will be re-indented,
> which will result in additional \t symbols in the string literal.
>
> I can undo this indentation with C-/ though, which is how I do it now.
If you are saying that the indentation inside string is incorrect in
general, then I agree we should fix it. (I don't use Go.) But then
please present the reproduction recipe which doesn't use another
language in the string, but simply has a string, which is corrupted by
indentation.
> > This use case, and others
> > like it, are supposed to be handled by features that support multiple
> > major modes in the same buffer.
>
> Thanks for the tip, I will take a look, for example indirect buffers can
> certainly improve my experience here.
>
> Best Regards,
> Gleb
>
This bug report was last modified 1 year and 179 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.