File tree Expand file tree Collapse file tree 3 files changed +24
-18
lines changed Expand file tree Collapse file tree 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
7777 $ lastTag = $ tag ;
7878
7979 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 ]['old ' ]['lines ' ] += $ formattedLines ;
89- $ blocks [$ lastBlock ]['new ' ]['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 ]['old ' ]['lines ' ] += $ this ->formatLines ($ lines );
85+ $ lines = \array_slice ($ new , $ j1 , $ j2 - $ j1 );
86+ $ blocks [$ lastBlock ]['new ' ]['lines ' ] += $ this ->formatLines ($ lines );
9187
9288 continue ;
9389 }
Original file line number Diff line number Diff line change @@ -124,7 +124,12 @@ protected function renderTableEqual(array $change): string
124124 {
125125 $ html = '' ;
126126
127- foreach ($ change ['old ' ]['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 ['old ' ]['lines ' ] as $ no => $ oldLine ) {
131+ // hmm... but this is a inline template
132+ // we could only pick a line from the old or the new to show
128133 $ oldLineNum = $ change ['old ' ]['offset ' ] + $ no + 1 ;
129134 $ newLineNum = $ change ['new ' ]['offset ' ] + $ no + 1 ;
130135
@@ -133,7 +138,7 @@ protected function renderTableEqual(array $change): string
133138 '<th class="n-old"> ' . $ oldLineNum . '</th> ' .
134139 '<th class="n-new"> ' . $ newLineNum . '</th> ' .
135140 '<th class="sign"></th> ' .
136- '<td class="old"> ' . $ line . '</td> ' .
141+ '<td class="old"> ' . $ oldLine . '</td> ' .
137142 '</tr> ' ;
138143 }
139144
Original file line number Diff line number Diff line change @@ -122,16 +122,21 @@ protected function renderTableEqual(array $change): string
122122 {
123123 $ html = '' ;
124124
125- foreach ($ change ['old ' ]['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 ['old ' ]['lines ' ] as $ no => $ oldLine ) {
129+ $ newLine = $ change ['new ' ]['lines ' ][$ no ];
130+
126131 $ oldLineNum = $ change ['old ' ]['offset ' ] + $ no + 1 ;
127- $ newLine = $ change ['new ' ]['offset ' ] + $ no + 1 ;
132+ $ newLineNum = $ change ['new ' ]['offset ' ] + $ no + 1 ;
128133
129134 $ html .=
130135 '<tr> ' .
131136 '<th class="n-old"> ' . $ oldLineNum . '</th> ' .
132- '<td class="old"> ' . $ line . '</td> ' .
133- '<th class="n-new"> ' . $ newLine . '</th> ' .
134- '<td class="new"> ' . $ line . '</td> ' .
137+ '<td class="old"> ' . $ oldLine . '</td> ' .
138+ '<th class="n-new"> ' . $ newLineNum . '</th> ' .
139+ '<td class="new"> ' . $ newLine . '</td> ' .
135140 '</tr> ' ;
136141 }
137142
You can’t perform that action at this time.
0 commit comments