bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#68781: [PATCH] Don't fill yaml except comments and block scalars.


From: Rudolf Schlatte
Subject: bug#68781: [PATCH] Don't fill yaml except comments and block scalars.
Date: Mon, 29 Jan 2024 09:20:04 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Randy Taylor <dev@rjt.dev> writes:

> On Sunday, January 28th, 2024 at 08:15, Rudolf Schlatte <rudi@constantly.at> 
> wrote:
>> 
>> Hi,
>> 
>> Currently, yaml-ts-mode fills comments and block scalars (multi-line
>> text literals) as expected, but re-fills the whole file when point is
>> outside of either of these constructs. Since yaml line breaks and
>> whitespace are significant, I'd say that this is never the correct
>> behavior.
>> 
>> This patch against current master inhibits M-q (fill-paragraph) outside
>> of comments and block scalars. In my tests default fill-paragraph
>> worked as expected both with and without justify, correctly detecting
>> comment and block literal boundaries, so I did not preserve the previous
>> code in `yaml-ts-mode--fill-paragraph'.
>
> Thanks for working on this.
>
> The previous implementation (see bug#68226) provided an example where:
> foo: |
>   line-one
>   line-two
>
> Would become:
> foo: | line-one line-two
>
> When it should be:
> foo: |
>   line-one line-two
>
> Your patch undoes this fix.
>
> I think I also ran into another bug using your patch: when inside a block
> scalar, for example, running fill-paragraph will re-fill the whole file (or
> parts of it at least).
>
> I agree that we shouldn't try to fill anything that isn't a comment or block
> scalar, and I also like the change in your other message where only the
> paragraph that point is on gets filled.
>
> BTW would it be possible to add tests for these? See `c-ts-mode-tests.el',
> specifically `c-ts-mode-test-filling', for inspiration.
>
> Graham, you added `yaml-ts-mode--fill-paragraph' - what are your thoughts? 
> See also Rudolf's other message.

Hello Randy, thanks for having a look!  Could you tell me which
tree-sitter grammar you are using?  I'm asking because with the grammar
from https://github.com/ikatyang/tree-sitter-yaml I don't see what you
describe.

Needless to say, please don't install the patch before I have debugged
this.  :)

Best, Rudi





reply via email to

[Prev in Thread] Current Thread [Next in Thread]