debian-mirror-gitlab/lib/gitlab/diff/inline_diff.rb

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

23 lines
521 B
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
2016-01-29 22:53:50 +05:30
module Gitlab
module Diff
class InlineDiff
2016-04-02 18:10:28 +05:30
attr_accessor :old_line, :new_line, :offset
2016-01-29 22:53:50 +05:30
2016-04-02 18:10:28 +05:30
def initialize(old_line, new_line, offset: 0)
2022-01-26 12:08:38 +05:30
@old_line = old_line[offset..]
@new_line = new_line[offset..]
2016-04-02 18:10:28 +05:30
@offset = offset
end
2021-04-17 20:07:23 +05:30
def inline_diffs
2016-04-02 18:10:28 +05:30
# Skip inline diff if empty line was replaced with content
return if old_line == ""
2021-04-17 20:07:23 +05:30
CharDiff.new(old_line, new_line).changed_ranges(offset: offset)
2016-04-02 18:10:28 +05:30
end
2016-01-29 22:53:50 +05:30
end
end
end