gitlab-org--gitlab-foss/lib/gitlab/string_regex_marker.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
448 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2016-07-10 20:17:20 +00:00
module Gitlab
class StringRegexMarker < StringRangeMarker
def mark(regex, group: 0, &block)
ranges = []
offset = 0
2016-07-10 20:17:20 +00:00
while match = regex.match(raw_line[offset..])
begin_index = match.begin(group) + offset
end_index = match.end(group) + offset
2016-07-10 20:17:20 +00:00
ranges << (begin_index..(end_index - 1))
offset = end_index
end
super(ranges, &block)
2016-07-10 20:17:20 +00:00
end
end
end