From 72e3b5f8f8afeb110ba6d7796fdddae707f86288 Mon Sep 17 00:00:00 2001 From: Reese Williams Date: Tue, 10 Nov 2026 08:45:51 +0900 Subject: [PATCH 1/2] Fixtures --- fixtures/small/shebang_np_actual.rb | 3 +++ fixtures/small/shebang_np_expected.rb | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 fixtures/small/shebang_np_actual.rb create mode 100644 fixtures/small/shebang_np_expected.rb diff --git a/fixtures/small/shebang_np_actual.rb b/fixtures/small/shebang_np_actual.rb new file mode 100644 index 00000000..adb53718 --- /dev/null +++ b/fixtures/small/shebang_np_actual.rb @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby -np + +next diff --git a/fixtures/small/shebang_np_expected.rb b/fixtures/small/shebang_np_expected.rb new file mode 100644 index 00000000..adb53718 --- /dev/null +++ b/fixtures/small/shebang_np_expected.rb @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby -np + +next From 84a45f19d5ac2e27bc3fe7a41d8e7be03a756242 Mon Sep 17 00:00:00 2001 From: Reese Williams Date: Tue, 10 Nov 2026 08:46:11 +0900 Subject: [PATCH 2/2] Add partial_script option to Prism invocation --- librubyfmt/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/librubyfmt/src/lib.rs b/librubyfmt/src/lib.rs index 03d8a8cb..505c5e15 100644 --- a/librubyfmt/src/lib.rs +++ b/librubyfmt/src/lib.rs @@ -69,7 +69,11 @@ pub fn format_buffer(buf: &[u8]) -> Result, RichFormatError> { .expect("writing to a vec should never fail"); } - let parse_result = ruby_prism::parse(buf); + let options = ruby_prism::Options::default() + // `partial_script` means Prism does not check jumps (next/break/etc.) for validity + .partial_script(true) + .build(); + let parse_result = ruby_prism::parse_with_options(buf, &options); if parse_result.errors().next().is_some() { return Err(RichFormatError::SyntaxError); }