Do not collapse line numbers that are indicated in the URL When users navigate to the diff view with a line number specified at the end, depending on their context preference, the line might be in a shared region that gets collapsed when the diff renders. With this change, the location specified in the URL is prevented from being collapsed by marking it as a "key" location. Bug: Issue 5247 Change-Id: Ifd5827cd922b022cddb1601911a9ecea6a054f35
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.html b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.html index 979f253..9a55bbe 100644 --- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.html +++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.html
@@ -646,6 +646,18 @@ assert.equal(element.$.cursor.side, 'right'); }); + test('_getLineOfInterest', () => { + assert.isNull(element._getLineOfInterest({})); + + let result = element._getLineOfInterest({lineNum: 12}); + assert.equal(result.number, 12); + assert.isNotOk(result.leftSide); + + result = element._getLineOfInterest({lineNum: 12, leftSide: true}); + assert.equal(result.number, 12); + assert.isOk(result.leftSide); + }); + test('_onLineSelected', () => { const getUrlStub = sandbox.stub(Gerrit.Nav, 'getUrlForDiffById'); const replaceStateStub = sandbox.stub(history, 'replaceState');