summaryrefslogtreecommitdiff
path: root/lib/syntax_suggest/code_line.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/syntax_suggest/code_line.rb')
-rw-r--r--lib/syntax_suggest/code_line.rb20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/syntax_suggest/code_line.rb b/lib/syntax_suggest/code_line.rb
index dc738ab128..76ca892ac3 100644
--- a/lib/syntax_suggest/code_line.rb
+++ b/lib/syntax_suggest/code_line.rb
@@ -48,12 +48,10 @@ module SyntaxSuggest
strip_line = line.dup
strip_line.lstrip!
- if strip_line.empty?
- @empty = true
- @indent = 0
+ @indent = if (@empty = strip_line.empty?)
+ line.length - 1 # Newline removed from strip_line is not "whitespace"
else
- @empty = false
- @indent = line.length - strip_line.length
+ line.length - strip_line.length
end
set_kw_end
@@ -184,10 +182,16 @@ module SyntaxSuggest
#
def trailing_slash?
last = @lex.last
- return false unless last
- return false unless last.type == :on_sp
- last.token == TRAILING_SLASH
+ # 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
# Endless method detection