Add GrDiffCursor.moveToLastChunk
The new method is analogous to GrDiffCursor.moveToFirstChunk, and can be used when navigating backwards through diffs. Change-Id: I0c53c3247d4b996fe0dcc0df65e5497494d7c9e7
This commit is contained in:
@@ -237,6 +237,11 @@
|
|||||||
this.moveToNextChunk(true);
|
this.moveToNextChunk(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
moveToLastChunk() {
|
||||||
|
this.$.cursorManager.moveToEnd();
|
||||||
|
this.moveToPreviousChunk();
|
||||||
|
}
|
||||||
|
|
||||||
reInitCursor() {
|
reInitCursor() {
|
||||||
this._updateStops();
|
this._updateStops();
|
||||||
if (this.initialLineNumber) {
|
if (this.initialLineNumber) {
|
||||||
|
|||||||
@@ -108,6 +108,18 @@ limitations under the License.
|
|||||||
assert.equal(cursorElement.diffRow, firstDeltaRow);
|
assert.equal(cursorElement.diffRow, firstDeltaRow);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('moveToLastChunk', () => {
|
||||||
|
const chunks = Array.from(Polymer.dom(diffElement.root).querySelectorAll(
|
||||||
|
'.section.delta'));
|
||||||
|
assert.isAbove(chunks.length, 1);
|
||||||
|
assert.equal(chunks.indexOf(cursorElement.diffRow.parentElement), 0);
|
||||||
|
|
||||||
|
cursorElement.moveToLastChunk();
|
||||||
|
|
||||||
|
assert.equal(chunks.indexOf(cursorElement.diffRow.parentElement),
|
||||||
|
chunks.length - 1);
|
||||||
|
});
|
||||||
|
|
||||||
test('cursor scroll behavior', () => {
|
test('cursor scroll behavior', () => {
|
||||||
cursorElement._handleDiffRenderStart();
|
cursorElement._handleDiffRenderStart();
|
||||||
assert.equal(cursorElement._scrollBehavior, 'keep-visible');
|
assert.equal(cursorElement._scrollBehavior, 'keep-visible');
|
||||||
|
|||||||
@@ -163,6 +163,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
moveToEnd() {
|
||||||
|
if (this.stops.length) {
|
||||||
|
this.setCursor(this.stops[this.stops.length - 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setCursorAtIndex(index, opt_noScroll) {
|
setCursorAtIndex(index, opt_noScroll) {
|
||||||
this.setCursor(this.stops[index], opt_noScroll);
|
this.setCursor(this.stops[index], opt_noScroll);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user