Skip to content

Suppress error highlight for some incomplete code#1173

Merged
tompng merged 2 commits intoruby:masterfrom
tompng:suppress_error_highlight
Feb 16, 2026
Merged

Suppress error highlight for some incomplete code#1173
tompng merged 2 commits intoruby:masterfrom
tompng:suppress_error_highlight

Conversation

@tompng
Copy link
Member

@tompng tompng commented Feb 15, 2026

It is better to not render class with RED-REVERSE color. Filter specific errors if error location is at the last non-newline non-comment token position.

class was rendered RED-REVERSE, will be rendered GREEN
class; will be rendered RED-REVESE as before

Detail

Many errors at the end should be highlighted

  • def f.@invalid_method_name
  • 1@a
  • :123
  • tap do end end

Only a few error types at the end should be filtered out

  • class
  • class a (followed by ::A is valid)
  • a,b (followed by =c is valid)
  • [*
  • f(**
  • f(&
  • def f =
  • =begin

Some patterns aren't possible to handle with the approach in this pull request

  • def $a (followed by .f is valid)
  • def $a.$a (invalid, same error will be raised)
  • *, (followed by a=b is valid, but error location is not at the end)

It is better to not render `class` with RED-REVERSE color.
Filter specific errors if error location is at the last non-newline non-comment token position.
@st0012 st0012 added the enhancement New feature or request label Feb 15, 2026
@tompng tompng merged commit 957fd79 into ruby:master Feb 16, 2026
40 checks passed
@tompng tompng deleted the suppress_error_highlight branch February 16, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments