Skip to content

Syntax highlighting issue with POSIX bracket expressions in regexes #228

Open

Description

@callmesangio

Hi, and thanks for this extension.

I just wanted to report that the syntax highlighting for regexes with POSIX bracket expressions seems a little bit off:

Image

This is with Zed 0.217.3 and Ruby extension 0.16.2.

Thanks!

Activity

  1. vitallium commented on Jan 6, 2026

    @vitallium
    Collaborator

    Thanks for reporting! This looks like an issue with the tree-sitter grammar. I've created an issue in upstream and will push a fix for it later.

  2. callmesangio commented on Jan 6, 2026

    @callmesangio
    Author

    Awesome, thanks!

  3. vitallium commented on Jan 6, 2026

    @vitallium
    Collaborator

    I've opened a pull request with a fix: tree-sitter/tree-sitter-ruby#285

  4. vitallium commented on Jan 6, 2026

    @vitallium
    Collaborator
    Before After
    Image Image
  5. vitallium commented on Jan 6, 2026

    @vitallium
    Collaborator

    Oh, wait. I think there is another issue with POSIX expressions.

  6. callmesangio commented on Jan 6, 2026

    @callmesangio
    Author

    Yes, I was reading everything and was about to ask. The POSIX expression should get both brackets highlighted, so this is probably something that goes beyond parsing of escape sequences.

  7. vitallium commented on Jan 6, 2026

    @vitallium
    Collaborator

    I think the provided regex is wrong: [[[:alpha:]]\d]+ The Ruby regexp engine is lenient and it allows such regexp but it's treated as [[:alpha:]]. This is a non-standard scenario, not sure if this is something that should be fixed in the regex tree-sitter grammar.

  8. callmesangio commented on Jan 6, 2026

    @callmesangio
    Author

    Apparently the two regexes behave differently though, I don't think they're equivalent:

    irb(main):001> RUBY_VERSION
    => "3.4.8"
    irb(main):002> /[[[:alpha:]]]+/.match "f1"
    => #<MatchData "f">
    irb(main):003> /[[[:alpha:]]\d]+/.match "f1"
    => #<MatchData "f1">
    irb(main):001> /\A[[[:alpha:]]]+\z/.match "f1"
    => nil
    irb(main):002> /\A[[[:alpha:]]\d]+\z/.match "f1"
    => #<MatchData "f1">
  9. added theissue type on Jan 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions