2018-11-05 23:45:35 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-01-15 10:02:48 -05:00
|
|
|
module Gitlab
|
|
|
|
module Diff
|
2016-07-10 16:10:59 -04:00
|
|
|
class InlineDiffMarker < Gitlab::StringRangeMarker
|
2018-04-03 05:57:31 -04:00
|
|
|
def initialize(line, rich_line = nil)
|
|
|
|
super(line, rich_line || line)
|
|
|
|
end
|
|
|
|
|
2021-03-11 10:09:10 -05:00
|
|
|
def mark(line_inline_diffs)
|
|
|
|
super(line_inline_diffs) do |text, left:, right:, mode:|
|
2019-11-26 10:06:50 -05:00
|
|
|
%{<span class="#{html_class_names(left, right, mode)}">#{text}</span>}.html_safe
|
2016-01-15 10:02:48 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-01-15 10:29:26 -05:00
|
|
|
private
|
|
|
|
|
2016-07-10 16:10:59 -04:00
|
|
|
def html_class_names(left, right, mode)
|
2016-04-06 15:37:09 -04:00
|
|
|
class_names = ["idiff"]
|
2016-07-10 16:10:59 -04:00
|
|
|
class_names << "left" if left
|
|
|
|
class_names << "right" if right
|
2016-04-06 15:37:09 -04:00
|
|
|
class_names << mode if mode
|
|
|
|
class_names.join(" ")
|
|
|
|
end
|
2016-01-15 10:02:48 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|