Skip to content

Commit 7ac69e5

Browse files
committed
[ruby/syntax_suggest] Handle on_sp 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. Ref: * ruby#15914 * ruby/prism#3859 ruby/syntax_suggest@42a3b8f6cb
1 parent 2d552a8 commit 7ac69e5

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)