Skip to content

Commit 355952f

Browse files
committed
refactor: Word line renderer uses PREG_SPLIT_NO_EMPTY
The previous "wordGlues" bug fix should've also fixed this. Signed-off-by: Jack Cherng <[email protected]>
1 parent 68b530e commit 355952f

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/Renderer/Html/LineRenderer/Word.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@ public function render(MbString $mbOld, MbString $mbNew): LineRendererInterface
2222
static $splitRegex = '/([' . RendererConstant::PUNCTUATIONS_RANGE . '])/uS';
2323
static $dummyHtmlClosure = RendererConstant::HTML_CLOSURES[0] . RendererConstant::HTML_CLOSURES[1];
2424

25-
// using PREG_SPLIT_NO_EMPTY will make "wordGlues" work wrongly under some rare cases
26-
// failure case:
27-
// old: "good-looking-x"
28-
// new: "good--y"
29-
// notice that after glueing, the 2nd "-" in the new should be in the diff segment
30-
$pregFlag = \PREG_SPLIT_DELIM_CAPTURE;
25+
$pregFlag = \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY;
3126
$oldWords = $mbOld->toArraySplit($splitRegex, -1, $pregFlag);
3227
$newWords = $mbNew->toArraySplit($splitRegex, -1, $pregFlag);
3328

0 commit comments

Comments
 (0)