Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rufo modifies escape characters #252

Open
phantomwhale opened this issue Nov 19, 2020 · 1 comment
Open

Rufo modifies escape characters #252

phantomwhale opened this issue Nov 19, 2020 · 1 comment

Comments

@phantomwhale
Copy link

With the code:

    def regexp
      %r{
        \b            #     word boundary
        ([\w\-.])     # $1: username; first letter
        @             #     at
        ([a-z\d\-.]+) # $2: domain except TLD
        \.            #     dot
        ([a-z]+)      # $3: TLD
        \b            #     word boundary
      }xi
    end

Running rufo (0.12.0 - running on Mac / ruby 2.6.5) changes this to:

    def regexp
      %r{
        ^H            #     word boundary
        ([\w\-.])     # $1: username; first letter
        @             #     at
        ([a-z\d\-.]+) # $2: domain except TLD
        \.            #     dot
        ([a-z]+)      # $3: TLD
        ^H           #     word boundary
      }xi
    end

E.g. the \b word boundary regex matcher is interpreted as backspace and then turned into the CTRL-H (backspace) control character on completion

@gingermusketeer
Copy link
Member

@phantomwhale I tried to reproduce this but was not able to. I wrote a test for the case you have here: https://github.com/ruby-formatter/rufo/compare/bug/regex-escape-characters?expand=1 but the tests pass in all versions of ruby.

Would you be able to do some more digging on your side? A PR with a failing test would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants