Skip to content

Honor custom formatters on runtimes without Ractor - #210

Open
ac1982 wants to merge 1 commit into
ruby:masterfrom
ac1982:fix/formatter-without-ractors
Open

ac1982 wants to merge 1 commit into
ruby:masterfrom
ac1982:fix/formatter-without-ractors

Conversation

@ac1982

@ac1982 ac1982 commented Oct 10, 2026

Copy link
Copy Markdown

On JRuby, assigning DidYouMean.formatter = CustomFormatter currently has no effect: the setter only writes inside the Ractor branch, and the getter always returns Formatter outside it. This also prevents callers from disabling suggestions with their own formatter.

Store and read the configured formatter on the module when Ractor is unavailable. The setting is shared between threads on those runtimes; Ractor-capable Rubies retain their existing per-Ractor storage. Assigning nil restores the default.

Fixes #191. Tests cover custom error-message rendering, resetting the formatter, and sharing the setting between threads without Ractor. The custom-formatter and cross-thread regressions both fail before the change on JRuby 9.4.8.0 / OpenJDK 21 / Linux arm64, and pass afterward.

Validation:

  • MRI 3.3.8: RUBYOPT=--disable-did_you_mean bundle exec rake — 82 tests, 249 assertions, no failures/errors.
  • JRuby 9.4.8.0: the Rake test file set loaded with the local lib and test paths, --disable-did_you_mean, and test-unit 3.7.8 — 76 tests, 224 assertions, no failures/errors, 2 pre-existing explicitly omitted JRuby cases. Ractor tests are not defined on JRuby.
  • git diff --check passed. Other versions and Windows were not run locally.

AI assistance: OpenAI Codex investigated, implemented, and ran these checks.

Signed-off-by: AC <ac@fabtek.cn>
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.

Formatters cannot be set/got when your implementation does not support Ractors

1 participant