Pass on CursorMoveResult
Allows clients to handle certain situation as they see fit, e.g. by
showing an info toast.
Change-Id: I2db8464a030ba762fe343a711a470c4d9b5a7ebf
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor.ts b/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor.ts
index fc7c870..81c6303 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor.ts
@@ -154,21 +154,21 @@
moveDown() {
if (this._getViewMode() === DiffViewMode.SIDE_BY_SIDE) {
- this.$.cursorManager.next({
+ return this.$.cursorManager.next({
filter: (row: Element) => this._rowHasSide(row),
});
} else {
- this.$.cursorManager.next();
+ return this.$.cursorManager.next();
}
}
moveUp() {
if (this._getViewMode() === DiffViewMode.SIDE_BY_SIDE) {
- this.$.cursorManager.previous({
+ return this.$.cursorManager.previous({
filter: (row: Element) => this._rowHasSide(row),
});
} else {
- this.$.cursorManager.previous();
+ return this.$.cursorManager.previous();
}
}
@@ -182,7 +182,10 @@
}
}
- moveToNextChunk(clipToTop?: boolean, navigateToNextFile?: boolean) {
+ moveToNextChunk(
+ clipToTop?: boolean,
+ navigateToNextFile?: boolean
+ ): CursorMoveResult {
const result = this.$.cursorManager.next({
filter: (row: HTMLElement) => this._isFirstRowOfChunk(row),
getTargetHeight: target =>
@@ -226,27 +229,31 @@
}
this._fixSide();
+ return result;
}
- moveToPreviousChunk() {
- this.$.cursorManager.previous({
+ moveToPreviousChunk(): CursorMoveResult {
+ const result = this.$.cursorManager.previous({
filter: (row: HTMLElement) => this._isFirstRowOfChunk(row),
});
this._fixSide();
+ return result;
}
- moveToNextCommentThread() {
- this.$.cursorManager.next({
+ moveToNextCommentThread(): CursorMoveResult {
+ const result = this.$.cursorManager.next({
filter: (row: HTMLElement) => this._rowHasThread(row),
});
this._fixSide();
+ return result;
}
- moveToPreviousCommentThread() {
- this.$.cursorManager.previous({
+ moveToPreviousCommentThread(): CursorMoveResult {
+ const result = this.$.cursorManager.previous({
filter: (row: HTMLElement) => this._rowHasThread(row),
});
this._fixSide();
+ return result;
}
moveToLineNumber(number: number, side: Side, path?: string) {