diff --git a/plugins/codemirror-editor b/plugins/codemirror-editor index 9508693bd0..d2c4dba2ac 160000 --- a/plugins/codemirror-editor +++ b/plugins/codemirror-editor @@ -1 +1 @@ -Subproject commit 9508693bd0a85560674143256314beac08f2d8ca +Subproject commit d2c4dba2ac2282e620e7ca2a63f8cbf803699c6b diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router.js b/polygerrit-ui/app/elements/core/gr-router/gr-router.js index bf649b8627..ebac1e163d 100644 --- a/polygerrit-ui/app/elements/core/gr-router/gr-router.js +++ b/polygerrit-ui/app/elements/core/gr-router/gr-router.js @@ -132,8 +132,8 @@ // eslint-disable-next-line max-len DIFF: /^\/c\/(.+)\/\+\/(\d+)(\/((-?\d+|edit)(\.\.(\d+|edit))?(\/(.+))))\/?$/, - // Matches /c//+//[]/,edit - DIFF_EDIT: /^\/c\/(.+)\/\+\/(\d+)\/(\d+|edit)\/(.+),edit$/, + // Matches /c//+//[]/,edit[#lineNum] + DIFF_EDIT: /^\/c\/(.+)\/\+\/(\d+)\/(\d+|edit)\/(.+),edit(\#\d+)?$/, // Matches non-project-relative // /c//[..]/. @@ -1394,6 +1394,7 @@ changeNum: ctx.params[1], patchNum: ctx.params[2], path: ctx.params[3], + lineNum: ctx.hash, view: Gerrit.Nav.View.EDIT, }); this.$.reporting.setRepoName(project); diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html index 3d93230cbf..f127a91e00 100644 --- a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html +++ b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html @@ -1541,6 +1541,37 @@ limitations under the License. view: Gerrit.Nav.View.EDIT, path: 'foo/bar/baz', patchNum: 3, + lineNum: undefined, + }; + + element._handleDiffEditRoute(ctx); + assert.isFalse(redirectStub.called); + assert.isTrue(normalizeRangeSpy.calledOnce); + assert.deepEqual(normalizeRangeSpy.lastCall.args[0], appParams); + assert.isFalse(normalizeRangeSpy.lastCall.returnValue); + assert.deepEqual(setParamsStub.lastCall.args[0], appParams); + }); + + test('_handleDiffEditRoute with lineNum', () => { + const normalizeRangeSpy = + sandbox.spy(element, '_normalizePatchRangeParams'); + sandbox.stub(element.$.restAPI, 'setInProjectLookup'); + const ctx = { + params: [ + 'foo/bar', // 0 Project + 1234, // 1 Change number + 3, // 2 Patch num + 'foo/bar/baz', // 3 File path + ], + hash: 4, + }; + const appParams = { + project: 'foo/bar', + changeNum: 1234, + view: Gerrit.Nav.View.EDIT, + path: 'foo/bar/baz', + patchNum: 3, + lineNum: 4, }; element._handleDiffEditRoute(ctx); diff --git a/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.html b/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.html index 7a1294dd07..1ae74e11af 100644 --- a/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.html +++ b/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.html @@ -123,6 +123,7 @@ limitations under the License. + diff --git a/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.js b/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.js index 12e16cffd3..64158d00f6 100644 --- a/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.js +++ b/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.js @@ -84,6 +84,7 @@ computed: '_computeSaveDisabled(_content, _newContent, _saving)', }, _prefs: Object, + _lineNum: Number, }; } @@ -126,6 +127,7 @@ this._changeNum = value.changeNum; this._path = value.path; this._patchNum = value.patchNum || this.EDIT_NAME; + this._lineNum = value.lineNum; // NOTE: This may be called before attachment (e.g. while parentElement is // null). Fire title-change in an async so that, if attachment to the DOM