Skip to content

Fix PromQL quoted and raw string highlighting - #1496

Merged
github-actions[bot] merged 3 commits into
alecthomas:masterfrom
anishpentyala:patch-1
Nov 17, 2026
Merged

github-actions[bot] merged 3 commits into
alecthomas:masterfrom
anishpentyala:patch-1

Conversation

@anishpentyala

Copy link
Copy Markdown
Contributor

PromQL allows single-quoted, double-quoted, and raw backtick strings. The quoted forms use backslash escapes, while raw strings can contain newlines.

The lexer currently ends a string on either quote type and does not account for escapes. That splits valid strings into incorrect tokens, including Error tokens. Raw backtick strings are not recognized either. In a label value, an escaped quote followed by a brace can also end the label state too early.

Use a shared string state for expressions and label values. Keep the existing Punctuation delimiters and LiteralString contents. Add golden coverage for escaped and opposite quotes, raw and multiline strings, braces inside label values, escaped trailing backslashes, and ordinary strings/selectors.

Validation on base and candidate:

  • Full ordinary suite with pinned Go 1.27.3 and shuffle seed 42 passes.
  • Go 1.25 and 1.27.3 race/shuffle runs pass with existing TestGet, TestLongTokensMatch, and TestLexers/OpenEdge_ABL excluded.
  • Focused PromQL tests pass on Linux/386.
  • With only the new golden copied to unchanged base, the new case fails while existing PromQL cases pass.

Candidate-only checks:

  • Focused PromQL race tests pass 100 times.
  • golangci-lint 2.15.0 passes.
  • Regenerating lexer metadata produces no change.
  • HTML output was rendered and visually checked against base.

Full race runs are not uniformly green: TestLongTokensMatch hits its existing regex timeout on both trees under Go 1.26.6, and also on the candidate in one pinned Go run. Bounded runs also hit an existing OpenEdge_ABL test timeout on both trees; default-order runs stalled at TestGet/ViaGoooFilename on both. Plain vet returns identical existing unkeyed Rule warnings on both trees.

This extends the PromQL support in #422 and #474 while retaining the metric-colon behavior from #1495.

The lexer XML has a trailing newline versus the original draft. The complete diff is three files, +166/-8.

@github-actions
github-actions Bot enabled auto-merge (squash) November 17, 2026 18:11
@github-actions
github-actions Bot merged commit c549397 into alecthomas:master Nov 17, 2026
4 checks passed
alecthomas added a commit that referenced this pull request Nov 21, 2026
GitHub reports a fork PR run held for maintainer approval with status
"completed" and conclusion "action_required", but auto-merge matched on
status. It never approved a held run, so first-time contributors' PRs
(#1496, #1522) sat until CI was approved by hand. Returning contributors
were unaffected because their runs are never held.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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

Successfully merging this pull request may close these issues.

1 participant