@@ -237,9 +237,6 @@ protected function renderChangedExtentLineLevel(MbString $mbFromLine, MbString $
237
237
*/
238
238
protected function renderChangedExtentCharLevel (MbString $ mbFromLine , MbString $ mbToLine ): self
239
239
{
240
- $ fromEditPos = $ mbFromLine ->strlen ();
241
- $ toEditPos = $ mbToLine ->strlen ();
242
-
243
240
// we prefer the char-level diff but if there is an exception like
244
241
// "line too long", we fallback to line-level diff.
245
242
try {
@@ -254,31 +251,25 @@ protected function renderChangedExtentCharLevel(MbString $mbFromLine, MbString $
254
251
}
255
252
256
253
// start to render
257
- foreach ($ editInfo ['progresses ' ] as [$ operation , $ position , , $ length ]) {
254
+ foreach ($ editInfo ['progresses ' ] as [$ operation , $ fromPos , $ toPos , $ length ]) {
258
255
switch ($ operation ) {
259
256
// default never happens though
260
257
default :
261
258
// copy, render nothing
262
259
case LD ::OP_COPY :
263
- $ fromEditPos -= $ length ;
264
- $ toEditPos -= $ length ;
265
260
break ;
266
261
// delete, render 'from'
267
262
case LD ::OP_DELETE :
268
- $ fromEditPos -= $ length ;
269
- $ mbFromLine ->str_enclose_i (self ::CLOSURES , $ fromEditPos , $ length );
263
+ $ mbFromLine ->str_enclose_i (self ::CLOSURES , $ fromPos , $ length );
270
264
break ;
271
265
// insert, render 'to'
272
266
case LD ::OP_INSERT :
273
- $ toEditPos -= $ length ;
274
- $ mbToLine ->str_enclose_i (self ::CLOSURES , $ toEditPos , $ length );
267
+ $ mbToLine ->str_enclose_i (self ::CLOSURES , $ toPos , $ length );
275
268
break ;
276
269
// replace, render both
277
270
case LD ::OP_REPLACE :
278
- $ fromEditPos -= $ length ;
279
- $ mbFromLine ->str_enclose_i (self ::CLOSURES , $ fromEditPos , $ length );
280
- $ toEditPos -= $ length ;
281
- $ mbToLine ->str_enclose_i (self ::CLOSURES , $ toEditPos , $ length );
271
+ $ mbFromLine ->str_enclose_i (self ::CLOSURES , $ fromPos , $ length );
272
+ $ mbToLine ->str_enclose_i (self ::CLOSURES , $ toPos , $ length );
282
273
break ;
283
274
}
284
275
}
0 commit comments