#UI_ENHANCEMENT by cg
authorClaus Gittinger <cg@exept.de>
Wed, 29 Nov 2017 11:41:18 +0100
changeset 17817 1b622818977b
parent 17816 ee2acbd6beab
child 17818 045764df016c
#UI_ENHANCEMENT by cg class: DiffTextView changed: #processDiffList:from:and:
DiffTextView.st
--- a/DiffTextView.st	Wed Nov 29 11:13:12 2017 +0100
+++ b/DiffTextView.st	Wed Nov 29 11:41:18 2017 +0100
@@ -297,7 +297,7 @@
     "given the two texts in text1 and text2, and the diff-output in diffList,
      return new left and right lists."
 
-    |idx1 idx2 dIdx dEnd state s nr1 nr2 nr3 op entry l1 l2 any delta s1 s2 line1 line2|
+    |idx1 idx2 dIdx dEnd state s nr1 nr2 nr3 op entry l1 l2 any delta s1 s2 line1 line2 common|
 
     diffList size == 1 ifTrue:[
         ^ { diffList. diffList }
@@ -433,7 +433,7 @@
                     useColors ifTrue:[
                         (l2 size >= idx1
                         and:[(s2 := line2 := l2 at:idx1) notNil
-                        and:[(line2 asString string withoutSeparators = (line1 := text1 at:idx1) asString string withoutSeparators)
+                        and:[(line2 asString string withTabsExpanded withoutSeparators = (line1 := text1 at:idx1) asString string withTabsExpanded withoutSeparators)
                               "/ or:[(s2 asString withoutSeparators withTabsExpanded = (text1 at:idx1) withoutSeparators withTabsExpanded)]  
                         ]]) ifTrue:[
                             line1 := Text string:line1 
@@ -470,7 +470,7 @@
                         useColors ifTrue:[
                             (l1 size >= idx2
                             and:[(s1 := line1 := l1 at:idx2) notNil
-                            and:[(s1 asString string withoutSeparators = (text2 at:idx2) string withoutSeparators)
+                            and:[(s1 asString string withTabsExpanded withoutSeparators = (text2 at:idx2) string withTabsExpanded withoutSeparators)
                                   "/ or:[(s1 asString withoutSeparators withTabsExpanded = (text2 at:idx2) withoutSeparators withTabsExpanded)]  
                             ]]) ifTrue:[
                                 line2 := Text string:(text2 at:idx2) 
@@ -492,11 +492,22 @@
                                 l2 add:line2.
                                 l1 at:idx2 put:line1.
                             ] ifFalse:[
-                                line2 := Text string:(text2 at:idx2) foregroundColor:changedColor backgroundColor:changedBgColor.
+                                line2 := text2 at:idx2.
+                                line1 notNil ifTrue:[
+                                    common := line1 string commonPrefixWith: line2 string.
+                                ] ifFalse:[
+                                    common := nil
+                                ].    
+                                common size > 0 ifTrue:[
+                                    line2 := (Text string:common foregroundColor:changedSpacesOnlyColor backgroundColor:changedSpacesOnlyBgColor)
+                                             , (Text string:(line2 copyFrom:common size+1) foregroundColor:changedColor backgroundColor:changedBgColor).
+                                ] ifFalse:[    
+                                    line2 := Text string:line2 foregroundColor:changedColor backgroundColor:changedBgColor.
+                                ].
                                 l2 add:line2
                             ]
                         ] ifFalse:[
-                            l2 add:(text2 at:idx2).
+                            l2 add:line2.
                         ].
                         idx2 := idx2 + 1
                     ] ifFalse:[
@@ -575,7 +586,7 @@
 
     ^ { l1. l2 }
 
-    "Modified: / 13.7.1999 / 14:12:11 / cg"
+    "Modified: / 29-11-2017 / 11:06:54 / cg"
 !
 
 updateListsFrom:text1 and:text2 diffs:diffList