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 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); }