Skip to content

Commit 20113a2

Browse files
Earlopaineregon
authored andcommitted
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.
1 parent 300927b commit 20113a2

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

lib/syntax_suggest/code_line.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,13 @@ def ignore_newline_not_beg?
180180
# EOM
181181
# expect(lines.first.trailing_slash?).to eq(true)
182182
#
183-
if SyntaxSuggest.use_prism_parser?
183+
if SyntaxSuggest.use_prism_parser? && Prism::VERSION <= "1.8.0"
184+
# Older versions of prism didn't correctly emit on_sp
184185
def trailing_slash?
185186
last = @lex.last
186-
last&.type == :on_tstring_end
187+
return false unless last
188+
189+
last.type == :on_tstring_end || (last.type == :on_sp && last.token == TRAILING_SLASH)
187190
end
188191
else
189192
def trailing_slash?

0 commit comments

Comments
 (0)