Fix syntax layer to work with skip chunks and empty ranges
The diff produced for comment context has skip chunks and it may also
produce empty ranges for the last (empty) line, which messes up the
syntax layer and its process/notify/annotate workflow.
Release-Notes: skip
Google-Bug-Id: b/219684547
Change-Id: Ie8425729b7f1af914cc720918a8763b0c409c8d4
diff --git a/polygerrit-ui/app/utils/syntax-util_test.ts b/polygerrit-ui/app/utils/syntax-util_test.ts
index 226f962..00464df 100644
--- a/polygerrit-ui/app/utils/syntax-util_test.ts
+++ b/polygerrit-ui/app/utils/syntax-util_test.ts
@@ -67,6 +67,19 @@
);
});
+ test('removal of empty spans', async () => {
+ assert.deepEqual(
+ highlightedStringToRanges('asdf<span class="c"></span>asdf'),
+ [{ranges: []}]
+ );
+ assert.deepEqual(
+ highlightedStringToRanges(
+ '<span class="d"></span>\n<span class="d"></span>'
+ ),
+ [{ranges: []}, {ranges: []}]
+ );
+ });
+
test('one line, two spans one after another', async () => {
assert.deepEqual(
highlightedStringToRanges(