Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ jobs:
fail-fast: false
matrix:
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
prism_version:
- 1.2.0 # Shipped with Ruby 3.4 as default parser https://www.ruby-lang.org/en/news/2024/12/25/ruby-3-4-0-released/
- 1.8.0
- head
env:
PRISM_VERSION: ${{ matrix.prism_version }}
steps:
- name: Checkout code
uses: actions/checkout@v6
Expand All @@ -40,6 +46,9 @@ jobs:
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Use latest prism version (head only)
if: matrix.prism_version == 'head'
run: bundle update prism
- name: test
run: bin/rake test
continue-on-error: ${{ matrix.ruby == 'head' }}
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## HEAD (unreleased)

- Fix: Correctly identify trailing slashes when using Prism > 1.8.0. (https://github.com/ruby/syntax_suggest/pull/243)
- Internal: Add tests to multiple versions of prism

## 2.0.2

- Fix: Separate multiple parser errors by newline. (https://github.com/ruby/syntax_suggest/pull/232)
Expand Down
10 changes: 9 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@ gem "standard"
gem "ruby-prof"

gem "benchmark-ips"
gem "prism"

case ENV["PRISM_VERSION"]&.strip&.downcase
when "head"
gem "prism", github: "ruby/prism"
when nil, ""
gem "prism"
else
gem "prism", ENV["PRISM_VERSION"]
end
19 changes: 9 additions & 10 deletions lib/syntax_suggest/code_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,17 @@ def ignore_newline_not_beg?
# EOM
# expect(lines.first.trailing_slash?).to eq(true)
#
if SyntaxSuggest.use_prism_parser?
def trailing_slash?
last = @lex.last
last&.type == :on_tstring_end
end
else
def trailing_slash?
last = @lex.last
return false unless last
return false unless last.type == :on_sp
def trailing_slash?
last = @lex.last

# 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

Expand Down