Merge "Fix syntax highlighting"
diff --git a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.ts b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.ts
index dddd6a4..f892410 100644
--- a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.ts
+++ b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.ts
@@ -559,13 +559,19 @@
    */
   _notify(state: SyntaxLayerState) {
     if (state.lineNums.left - state.lastNotify.left) {
-      this._notifyRange(state.lastNotify.left, state.lineNums.left, Side.LEFT);
+      this._notifyRange(
+        state.lastNotify.left,
+        // We have to notify 1-based inclusive, so subtract 1.
+        state.lineNums.left - 1,
+        Side.LEFT
+      );
       state.lastNotify.left = state.lineNums.left;
     }
     if (state.lineNums.right - state.lastNotify.right) {
       this._notifyRange(
         state.lastNotify.right,
-        state.lineNums.right,
+        // We have to notify 1-based inclusive, so subtract 1.
+        state.lineNums.right - 1,
         Side.RIGHT
       );
       state.lastNotify.right = state.lineNums.right;
diff --git a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer_test.js b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer_test.js
index c907a80..2b03bd3 100644
--- a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer_test.js
+++ b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer_test.js
@@ -171,6 +171,7 @@
     window.hljs = mockHLJS;
     const highlightSpy = sinon.spy(mockHLJS, 'highlight');
     const processNextSpy = sinon.spy(element, '_processNextLine');
+    const notifyRangeSpy = sinon.spy(element, '_notifyRange');
     await element.process();
 
     const linesA = diff.meta_a.lines;
@@ -182,6 +183,11 @@
 
     assert.equal(highlightSpy.callCount, linesA + linesB);
 
+    assert.isTrue(notifyRangeSpy.called);
+    assert.equal(notifyRangeSpy.lastCall.args[0], 44);
+    assert.equal(notifyRangeSpy.lastCall.args[1], 48);
+    assert.equal(notifyRangeSpy.lastCall.args[2], 'right');
+
     // The first line of both sides have a range.
     let ranges = [element.baseRanges[0], element.revisionRanges[0]];
     for (const range of ranges) {
diff --git a/polygerrit-ui/app/types/types.ts b/polygerrit-ui/app/types/types.ts
index 42f3d45..c6137eb 100644
--- a/polygerrit-ui/app/types/types.ts
+++ b/polygerrit-ui/app/types/types.ts
@@ -171,7 +171,9 @@
 }
 
 export type DiffLayerListener = (
+  /** 1-based inclusive */
   start: number,
+  /** 1-based inclusive */
   end: number,
   side: Side
 ) => void;