Merge "Add support for going to linNum in inline editor"

* submodules:
* Update plugins/codemirror-editor from branch 'master'
  to d2c4dba2ac2282e620e7ca2a63f8cbf803699c6b
  - Add support to scroll to line
    
    Bug: Issue 12364
    Change-Id: I0e58a78eb93acfcb6e4bee639a66710a6341660f
This commit is contained in:
Paladox none
2020-03-04 16:49:48 +00:00
committed by Gerrit Code Review
5 changed files with 38 additions and 3 deletions

View File

@@ -132,8 +132,8 @@
// eslint-disable-next-line max-len
DIFF: /^\/c\/(.+)\/\+\/(\d+)(\/((-?\d+|edit)(\.\.(\d+|edit))?(\/(.+))))\/?$/,
// Matches /c/<project>/+/<changeNum>/[<patchNum|edit>]/<path>,edit
DIFF_EDIT: /^\/c\/(.+)\/\+\/(\d+)\/(\d+|edit)\/(.+),edit$/,
// Matches /c/<project>/+/<changeNum>/[<patchNum|edit>]/<path>,edit[#lineNum]
DIFF_EDIT: /^\/c\/(.+)\/\+\/(\d+)\/(\d+|edit)\/(.+),edit(\#\d+)?$/,
// Matches non-project-relative
// /c/<changeNum>/[<basePatchNum>..]<patchNum>/<path>.
@@ -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);

View File

@@ -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);

View File

@@ -123,6 +123,7 @@ limitations under the License.
<gr-endpoint-param name="fileContent" value="[[_newContent]]"></gr-endpoint-param>
<gr-endpoint-param name="prefs" value="[[_prefs]]"></gr-endpoint-param>
<gr-endpoint-param name="fileType" value="[[_type]]"></gr-endpoint-param>
<gr-endpoint-param name="lineNum" value="[[_lineNum]]"></gr-endpoint-param>
<gr-default-editor id="file" file-content="[[_newContent]]"></gr-default-editor>
</gr-endpoint-decorator>
</div>

View File

@@ -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