--- a/Tools__Diff3CodeView2.st Fri Mar 16 22:44:50 2012 +0000
+++ b/Tools__Diff3CodeView2.st Fri Mar 16 23:23:39 2012 +0000
@@ -180,11 +180,17 @@
!Diff3CodeView2::Diff3Data methodsFor:'computing'!
addLines: total from: src to: dst offset: offset length: len
+ | start stop |
- offset to: offset + len - 1 do:[:i|
- dst add: (src at: i).
+ start := offset min: src size.
+ stop := (offset + len - 1) min: src size.
+
+ start < stop ifTrue:[
+ start to: stop do:[:i|
+ dst add: (src at: i).
+ ].
].
- (total - len) timesRepeat: [ dst add: nil ].
+ (total - (stop - start + 1)) timesRepeat: [ dst add: nil ].
"Created: / 16-03-2012 / 22:20:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
@@ -192,15 +198,22 @@
computeDiffDataForText1:t1 text2:t2 text3: t3
| t1c t2c t3c diff3chunks lnr |
- t1c := (text1 := t1) asStringCollection.
- t2c := (text2 := t2) asStringCollection.
- t3c := (text3 := t3) asStringCollection.
list1 := StringCollection new.
list2 := StringCollection new.
list3 := StringCollection new.
changed := OrderedCollection new.
inserted2 := OrderedCollection new.
inserted3 := OrderedCollection new.
+
+ t1 isNil ifTrue:[ ^self ].
+ t2 isNil ifTrue:[ ^self ].
+ t3 isNil ifTrue:[ ^self ].
+
+
+ t1c := (text1 := t1) asStringCollection.
+ t2c := (text2 := t2) asStringCollection.
+ t3c := (text3 := t3) asStringCollection.
+
diff3chunks := Diff3 new
file0: t1c; "/Base version
@@ -225,16 +238,16 @@
self addLines: len from: t1c to: list3 offset: chunk offset length: len.
].
chunk side == #left ifTrue:[
- self addLines: len from: t1c to: list1 offset: chunk offset length: 0.
+ self addLines: len from: t1c to: list1 offset: chunk offset length: len.
self addLines: len from: t2c to: list2 offset: chunk offset length: len.
- self addLines: len from: t3c to: list3 offset: chunk offset length: 0.
- lnr to:(lnr + len -1) do:[:i|inserted2 add: i].
+ self addLines: len from: t3c to: list3 offset: chunk offset length: len.
+ lnr to:(lnr + len - 1) do:[:i| changed add:i ].
].
chunk side == #right ifTrue:[
- self addLines: len from: t1c to: list1 offset: chunk offset length: 0.
- self addLines: len from: t2c to: list2 offset: chunk offset length: 0.
+ self addLines: len from: t1c to: list1 offset: chunk offset length: len.
+ self addLines: len from: t2c to: list2 offset: chunk offset length: len.
self addLines: len from: t3c to: list3 offset: chunk offset length: len.
- lnr to:(lnr + len -1) do:[:i|inserted3 add: i].
+ lnr to:(lnr + len - 1) do:[:i|changed add: i].
]
].
lnr := lnr + len.
@@ -246,5 +259,5 @@
!Diff3CodeView2 class methodsFor:'documentation'!
version_SVN
- ^ '$Id: Tools__Diff3CodeView2.st 7936 2012-03-16 22:44:50Z vranyj1 $'
+ ^ '$Id: Tools__Diff3CodeView2.st 7937 2012-03-16 23:23:39Z vranyj1 $'
! !