diff --git a/core_gem/lib/deep_cover/tools/scan_match_datas.rb b/core_gem/lib/deep_cover/tools/scan_match_datas.rb index 76da0ea9..aaf703a3 100644 --- a/core_gem/lib/deep_cover/tools/scan_match_datas.rb +++ b/core_gem/lib/deep_cover/tools/scan_match_datas.rb @@ -4,7 +4,16 @@ module DeepCover module Tools::ScanMatchDatas # Like String#scan, but return the MatchData object instead def scan_match_datas(source, matcher) - source.to_enum(:scan, matcher).map { Regexp.last_match } + # This has wrong behavior in truffleruby + # source.to_enum(:scan, matcher).map { Regexp.last_match } + # This is the fool-proof way of doing it. Maybe some checks for perf should be done + start_at = 0 + matches = [] + while (match = source.match(matcher, start_at)) + matches.push(match) + start_at = match.end(0) + end + matches end end end