diff --git a/lib/syntax_suggest/code_line.rb b/lib/syntax_suggest/code_line.rb index 892c273c41..76ca892ac3 100644 --- a/lib/syntax_suggest/code_line.rb +++ b/lib/syntax_suggest/code_line.rb @@ -180,21 +180,17 @@ module SyntaxSuggest # EOM # expect(lines.first.trailing_slash?).to eq(true) # - if SyntaxSuggest.use_prism_parser? && Prism::VERSION <= "1.8.0" - # Older versions of prism didn't correctly emit on_sp - def trailing_slash? - last = @lex.last - return false unless last - - last.type == :on_tstring_end || (last.type == :on_sp && last.token == TRAILING_SLASH) - end - else - def trailing_slash? - last = @lex.last - return false unless last - return false unless last.type == :on_sp + def trailing_slash? + last = @lex.last + # Older versions of prism diverged slightly from Ripper in compatibility mode + case last&.type + when :on_sp last.token == TRAILING_SLASH + when :on_tstring_end + true + else + false end end