google / yamlfmt

An extensible command line tool or library to format yaml files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Basic formatter spuriously deletes backslashes in strings after glob run

navijation opened this issue · comments

When running yamlfmt basic formatting with a config file and targeting several paths in a repository, the formatter spuriously deletes backslashes and thereby breaks the semantics of those YAML files. For example

outer:
    - inner: "python3 -m some.module \\${VARIABLE_:-}" 

becomes

outer:
    - inner: "python3 -m some.module ${VARIABLE_:-}" 

and

outer:
  - name: something
    regex: '\(\d+, "Unknown database .*'

becomes

outer:
  - name: something
    regex: '(d+, "Unknown database .*'

which are not semantically identical. Strangely enough, targeting these individual files with the formatter doesn't change them this way. Only running the formatter over a glob of YAML paths in my directory has this effect.

Unfortunately, I can't attach the entire directory as it's proprietary. But I'm hoping you have some insights as to why this might happen. I'll try to create a sanitized reproduction if possible.

Thanks for bringing this to my attention!

This appears to be a bug with emoji_support. When I turn it off it doesn't remove the backslashes. I think I know what I did wrong and will make a PR for it ASAP.