summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEarlopain <14981592+Earlopain@users.noreply.github.com>2026-01-20 13:38:50 +0100
committerTakashi Kokubun <takashikkbn@gmail.com>2026-01-21 10:11:17 -0800
commitbbba57f22c7eb7279297e03f8124d51135a7e87a (patch)
tree0019cc2b04c17b5ced752c099a54b7f2211df4e7
parent26777e8a79a43dcf86c10274af4507bd196b9050 (diff)
[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: * https://github.com/ruby/ruby/pull/15914 * https://github.com/ruby/prism/pull/3859 https://github.com/ruby/syntax_suggest/commit/42a3b8f6cb
-rw-r--r--lib/syntax_suggest/code_line.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/syntax_suggest/code_line.rb b/lib/syntax_suggest/code_line.rb
index 58197e95d0..892c273c41 100644
--- a/lib/syntax_suggest/code_line.rb
+++ b/lib/syntax_suggest/code_line.rb
@@ -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?