summaryrefslogtreecommitdiff
path: root/lib/gitlab/diff/parser.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/diff/parser.rb')
-rw-r--r--lib/gitlab/diff/parser.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/gitlab/diff/parser.rb b/lib/gitlab/diff/parser.rb
index 8f844224a7a..742f989c50b 100644
--- a/lib/gitlab/diff/parser.rb
+++ b/lib/gitlab/diff/parser.rb
@@ -11,6 +11,7 @@ module Gitlab
line_old = 1
line_new = 1
type = nil
+ context = nil
# By returning an Enumerator we make it possible to search for a single line (with #find)
# without having to instantiate all the others that come after it.
@@ -31,7 +32,8 @@ module Gitlab
line_obj_index += 1
next
elsif line[0] == '\\'
- type = 'nonewline'
+ type = "#{context}-nonewline"
+
yielder << Gitlab::Diff::Line.new(full_line, type, line_obj_index, line_old, line_new)
line_obj_index += 1
else
@@ -43,8 +45,10 @@ module Gitlab
case line[0]
when "+"
line_new += 1
+ context = :new
when "-"
line_old += 1
+ context = :old
when "\\" # rubocop:disable Lint/EmptyWhen
# No increment
else