File tree 3 files changed +24
-18
lines changed 3 files changed +24
-18
lines changed Original file line number Diff line number Diff line change @@ -77,17 +77,13 @@ public function getChanges(): array
77
77
$ lastTag = $ tag ;
78
78
79
79
if ($ tag === SequenceMatcher::OP_EQ ) {
80
- /**
81
- * @todo Technically this is wrong.
82
- * The old and the new may not be exactly the same
83
- * because of ignoreCase and ignoreWhitespace.
84
- */
85
- if (!empty ($ lines = \array_slice ($ old , $ i1 , $ i2 - $ i1 ))) {
86
- $ formattedLines = $ this ->formatLines ($ lines );
87
-
88
- $ blocks [$ lastBlock ]['base ' ]['lines ' ] += $ formattedLines ;
89
- $ blocks [$ lastBlock ]['changed ' ]['lines ' ] += $ formattedLines ;
90
- }
80
+ // note that although we are in a OP_EQ situation,
81
+ // the old and the new may not be exactly the same
82
+ // because of ignoreCase, ignoreWhitespace, etc
83
+ $ lines = \array_slice ($ old , $ i1 , $ i2 - $ i1 );
84
+ $ blocks [$ lastBlock ]['base ' ]['lines ' ] += $ this ->formatLines ($ lines );
85
+ $ lines = \array_slice ($ new , $ j1 , $ j2 - $ j1 );
86
+ $ blocks [$ lastBlock ]['changed ' ]['lines ' ] += $ this ->formatLines ($ lines );
91
87
92
88
continue ;
93
89
}
Original file line number Diff line number Diff line change @@ -124,7 +124,12 @@ protected function renderTableEqual(array $change): string
124
124
{
125
125
$ html = '' ;
126
126
127
- foreach ($ change ['base ' ]['lines ' ] as $ no => $ line ) {
127
+ // note that although we are in a OP_EQ situation,
128
+ // the old and the new may not be exactly the same
129
+ // because of ignoreCase, ignoreWhitespace, etc
130
+ foreach ($ change ['base ' ]['lines ' ] as $ no => $ oldLine ) {
131
+ // hmm... but this is a inline template
132
+ // we could only pick a line from the base or the changed to show
128
133
$ oldLineNum = $ change ['base ' ]['offset ' ] + $ no + 1 ;
129
134
$ newLineNum = $ change ['changed ' ]['offset ' ] + $ no + 1 ;
130
135
@@ -133,7 +138,7 @@ protected function renderTableEqual(array $change): string
133
138
'<th class="f-num"> ' . $ oldLineNum . '</th> ' .
134
139
'<th class="t-num"> ' . $ newLineNum . '</th> ' .
135
140
'<th class="sign"></th> ' .
136
- '<td class="old"> ' . $ line . '</td> ' .
141
+ '<td class="old"> ' . $ oldLine . '</td> ' .
137
142
'</tr> ' ;
138
143
}
139
144
Original file line number Diff line number Diff line change @@ -122,16 +122,21 @@ protected function renderTableEqual(array $change): string
122
122
{
123
123
$ html = '' ;
124
124
125
- foreach ($ change ['base ' ]['lines ' ] as $ no => $ line ) {
125
+ // note that although we are in a OP_EQ situation,
126
+ // the old and the new may not be exactly the same
127
+ // because of ignoreCase, ignoreWhitespace, etc
128
+ foreach ($ change ['base ' ]['lines ' ] as $ no => $ oldLine ) {
129
+ $ newLine = $ change ['changed ' ]['lines ' ][$ no ];
130
+
126
131
$ oldLineNum = $ change ['base ' ]['offset ' ] + $ no + 1 ;
127
- $ newLine = $ change ['changed ' ]['offset ' ] + $ no + 1 ;
132
+ $ newLineNum = $ change ['changed ' ]['offset ' ] + $ no + 1 ;
128
133
129
134
$ html .=
130
135
'<tr> ' .
131
136
'<th class="f-num"> ' . $ oldLineNum . '</th> ' .
132
- '<td class="old"> ' . $ line . '</td> ' .
133
- '<th class="t-num"> ' . $ newLine . '</th> ' .
134
- '<td class="new"> ' . $ line . '</td> ' .
137
+ '<td class="old"> ' . $ oldLine . '</td> ' .
138
+ '<th class="t-num"> ' . $ newLineNum . '</th> ' .
139
+ '<td class="new"> ' . $ newLine . '</td> ' .
135
140
'</tr> ' ;
136
141
}
137
142
You can’t perform that action at this time.
0 commit comments