ruby-formatter/rufo

0d0a is replaced with literal line break

jcronk opened this issue · 3 comments

I have multiple situations where I need to check for exactly those two characters in order, or to consume those two characters because I need them. When I reformat something with Rufo, this:

record_separator = "\x0d\x0a"

becomes

record_separator = "
"

And that is bad because in this situation, for example, I'm checking for end of record in a line of data from an EBCDIC text file from a mainframe (yes, for some reason they almost always use ASCII crlf as record separators in my experience). If the separator character becomes a literal line break, it becomes just a \x0a and the carriage return character stays (because I'm using either Linux or a Mac), which means that it doesn't consume the entire EOR sequence and I get an error. Not to mention putting a literal line break in quotes like that just looks weird.

But basically, I've had two gems so far that this broke, and when I tracked down the reason, it was this behavior. Can you change it so that it leaves these sequences alone? This also happens if I'm matching inside a regular expression, so it seems like any quote-like construct that takes escaped hex characters will get them replaced by literals, but in these cases I want them to be the escaped characters and changing them breaks things.

@jcronk I have tried to reproduce this issue but have not been able to. What version of ruby and rufo are you using?

@gingermusketeer You know what, I was using it through the Vim plugin and it looks like the plugin is doing it. If I just run :%!rufo I don't see the character being replaced. Sorry about that! I'll go over there an open an issue.