summaryrefslogtreecommitdiffstats
path: root/vendor/diff-display
diff options
context:
space:
mode:
authorJohan Sørensen <johan@johansorensen.com>2009-11-02 15:53:31 +0100
committerJohan Sørensen <johan@johansorensen.com>2009-11-04 15:23:46 +0100
commit6af131bff899ce46221945270b8cc95ac45aaa03 (patch)
tree6a6d5b2ae66b0ff9f665654c09584edfe6600478 /vendor/diff-display
parentde157184b84cca3c034f81c6975351d1658cb73d (diff)
downloadgitorious-mainline-outdated-6af131bff899ce46221945270b8cc95ac45aaa03.zip
gitorious-mainline-outdated-6af131bff899ce46221945270b8cc95ac45aaa03.tar.gz
gitorious-mainline-outdated-6af131bff899ce46221945270b8cc95ac45aaa03.tar.bz2
Store affected lines of an inline diff comment correctly
In order to be able to place the comment correctly in the diff we now store a tuple of [old_linenumber, new_line_number] along with the number of lines the comment spans. We store both the first and the last line number tuple so that we can calculate the placement of things generated outside the DOM tree (such as the InlineTableCallback diff rendering callback).
Diffstat (limited to 'vendor/diff-display')
-rw-r--r--vendor/diff-display/lib/diff/display/data_structure.rb29
-rw-r--r--vendor/diff-display/lib/diff/display/unified/generator.rb8
-rw-r--r--vendor/diff-display/test/test_helper.rb2
3 files changed, 16 insertions, 23 deletions
diff --git a/vendor/diff-display/lib/diff/display/data_structure.rb b/vendor/diff-display/lib/diff/display/data_structure.rb
index 1da658c..8531711 100644
--- a/vendor/diff-display/lib/diff/display/data_structure.rb
+++ b/vendor/diff-display/lib/diff/display/data_structure.rb
@@ -68,12 +68,12 @@ module Diff
# a SepLine class which represents all the lines that aren't part of the diff.
class Line < String
class << self
- def add(line, line_number, inline = false)
- AddLine.new(line, line_number, inline)
+ def add(line, line_number, inline = false, offsets = [])
+ AddLine.new(line, line_number, inline, offsets)
end
- def rem(line, line_number, inline = false)
- RemLine.new(line, line_number, inline)
+ def rem(line, line_number, inline = false, offsets = [])
+ RemLine.new(line, line_number, inline, offsets)
end
def unmod(line, old_number, new_number)
@@ -126,30 +126,23 @@ module Diff
%Q{#<#{self.class.name} [#{old_number.inspect}-#{new_number.inspect}] "#{self}">}
end
end
-
- # class AddLine < Line
- # def initialize(line, line_number)
- # super(line, nil, line_number)
- # end
- # end
- #
- # class RemLine < Line
- # def initialize(line, line_number)
- # super(line, line_number, nil)
- # end
- # end
+
class AddLine < Line
- def initialize(line, line_number, inline = false)
+ def initialize(line, line_number, inline = false, offsets = [])
super(line, nil, line_number)
@inline = inline
+ @offsets = offsets
end
+ attr_reader :offsets
end
class RemLine < Line
- def initialize(line, line_number, inline = false)
+ def initialize(line, line_number, inline = false, offsets = [])
super(line, line_number, nil)
@inline = inline
+ @offsets = offsets
end
+ attr_reader :offsets
end
class NonewlineLine < Line
diff --git a/vendor/diff-display/lib/diff/display/unified/generator.rb b/vendor/diff-display/lib/diff/display/unified/generator.rb
index cccd09d..5439868 100644
--- a/vendor/diff-display/lib/diff/display/unified/generator.rb
+++ b/vendor/diff-display/lib/diff/display/unified/generator.rb
@@ -119,10 +119,10 @@ module Diff::Display
case type
when :add
@offset[1] += 1
- current_block << Line.send(type, line, @offset[1], inline)
+ current_block << Line.send(type, line, @offset[1], inline, @offset.dup)
when :rem
@offset[0] += 1
- current_block << Line.send(type, line, @offset[0], inline)
+ current_block << Line.send(type, line, @offset[0], inline, @offset.dup)
# when :rmod
# @offset[0] += 1
# @offset[1] += 1 # TODO: is that really correct?
@@ -167,7 +167,7 @@ module Diff::Display
def add_separator
push SepBlock.new
- current_block << SepLine.new
+ current_block << SepLine.new
end
def car(line)
@@ -207,4 +207,4 @@ module Diff::Display
return [start, ending + 1]
end
end
-end \ No newline at end of file
+end
diff --git a/vendor/diff-display/test/test_helper.rb b/vendor/diff-display/test/test_helper.rb
index 323d323..1b67a30 100644
--- a/vendor/diff-display/test/test_helper.rb
+++ b/vendor/diff-display/test/test_helper.rb
@@ -22,4 +22,4 @@ module DiffFixtureHelper
def load_diff(name)
File.read(File.dirname(__FILE__) + "/fixtures/#{name}.diff")
end
-end \ No newline at end of file
+end