AndrewRadev/splitjoin.vim

YAML splitting flow-object with path as value fails to round-trip from joining

moll opened this issue · 3 comments

moll commented

Hey again!

I think I found a bug in the YAML splitting functionality or I'm doing something against the YAML standard that just happens to work one-way.

Given the following:

- copy:
    dest: /etc/default/locale
    content: "LANG=en_US.UTF-8\n"

Joining on copy: works fine. You get:

- copy: {dest: /etc/default/locale, content: "LANG=en_US.UTF-8\n"}

However splitting back ends with:

- copy:
    dest: /etc/default/locale, content: "LANG=en_US.UTF-8\n"

If you quote the file path as shown below, it works fine.

- copy: {dest: "/etc/default/locale", content: "LANG=en_US.UTF-8\n"}

Splits into:

- copy:
    dest: "/etc/default/locale"
    content: "LANG=en_US.UTF-8\n"

I'm not sure what the YAML spec says about barewords, but I figured you know for sure whether it's a bug or working as intended.

Thanks in advance!

Yes, dest: /path should work just fine in YAML. The reason it was broken was because I've been reusing the parser for JSON items, except it was based on javascript, so it was jumping over / characters as starting and ending points of /regexes/.

Anyway, I think this issue should be fixed now, let me know if you can confirm it on your side.

moll commented

Works brilliantly. Thanks again and next time you're in Estonia, let me know and lunch is on me!

Hahah, awesome, I'll definitely schedule a visit some day :D