GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Complex string incorrectly highlights as quoted symbol · Issue #449 · vim-ruby/vim-ruby

Complex string incorrectly highlights as quoted symbol #449

New issue
Copy link
New issue
Copy link
Open
Open
Complex string incorrectly highlights as quoted symbol#449
Copy link
Labels
syntax

Description

@matthewd
matthewd
opened on May 24, 2022
Issue body actions

Given:

puts("a#{":b"}c")

The inner ": sequence pairs with the opening quote, making a part of a quoted symbol hash key. The #{..} subexpression itself still highlights correctly, but c is not part of any quoted construct (and consequently the closing quote instead starts a new string, messing up the rest of the file).

This feels like it might be unsolvably edge-casey, but I'm regularly astounded by how well this syntax handles very questionable code, so I figured it's at least worth reporting. 🤷🏻‍♂️

I encountered this pattern in the wild in this file: https://github.com/rails/rails/blob/40272988cec849c734ec02cfa89ff830ae019d9e/actionpack/lib/action_controller/metal/strong_parameters.rb#L51

Activity

  1. dkearns
    added
    syntax
    on May 24, 2022
  2. dkearns commented on May 24, 2022

    @dkearns
    dkearns
    on May 24, 2022
    Member
    More actions

    No fix yet.

    vim-ruby/syntax/ruby.vim

    Line 474 in 55335f2

    syn match rubySymbol "\"\%(\\.\|[^\"]\)*\"::\@!"he=e-1 contains=@rubyStringSpecial,rubyDoubleQuoteSymbolDelimiter

  3. AndrewRadev commented on Dec 23, 2022

    @AndrewRadev
    AndrewRadev
    on Dec 23, 2022
    Member
    More actions

    Another example I ran into that hits the same issue, I think:

    output: {
      'loglevel' => 'fatal',
      vf: 'scale=\'min(400\, iw):min(400\, ih)\':force_original_aspect_ratio=decrease',
    }.freeze,

    2022-12-23-202151_1920x1080_scrot

    I managed to patch it locally by adding a check for the lack of \ before ', but that's really a workaround

    -syn match rubySymbol "'\%(\\.\|[^']\)*'::\@!"he=e-1 contains=rubyQuoteEscape,rubyBackslashEscape,rubySingleQuoteSymbolDelimiter
    +syn match rubySymbol "'\%(\\.\|[^\']\)*'::\@!"he=e-1 contains=rubyQuoteEscape,rubyBackslashEscape,rubySingleQuoteSymbolDelimiter

    It's weird that it's even trying to highlight ...min(400\, ih)\':force_... as a symbol, it shouldn't be contained inside one. I don't know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    syntax

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.