Handle on_sp in syntax_suggest when using prism

It used to not emit this token type, but now it does.
So when a newer version of prism is present, we can fall back
to the same code that ripper uses.
This commit is contained in:
Earlopain 2026-01-20 12:16:20 +01:00 committed by Benoit Daloze
parent 300927b4bb
commit 20113a228d
Notes: git 2026-01-20 13:19:03 +00:00

View File

@ -180,10 +180,13 @@ module SyntaxSuggest
# EOM
# expect(lines.first.trailing_slash?).to eq(true)
#
if SyntaxSuggest.use_prism_parser?
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
last&.type == :on_tstring_end
return false unless last
last.type == :on_tstring_end || (last.type == :on_sp && last.token == TRAILING_SLASH)
end
else
def trailing_slash?