diff options
Diffstat (limited to 'src/snapshot.c')
| -rw-r--r-- | src/snapshot.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/snapshot.c b/src/snapshot.c index 3869be4..29ed98c 100644 --- a/src/snapshot.c +++ b/src/snapshot.c @@ -189,17 +189,26 @@ static bool term_snapshot_update_inner(struct term_snapshot *s, struct term *t) if (!all && rows > 1) { int cand_k = 0; /* Find candidate scroll offset k by checking where top rows moved. */ - for (int p = 0; p < 2 && p < rows - 1 && !cand_k; p++) { - uint64_t key = new_keys[p]; - if (!key) - continue; - for (int k = 1; p + k < rows; k++) { - if (s->keys[p + k] == key) { + uint64_t key0 = new_keys[0]; + if (key0) { + for (int k = 1; k < rows; k++) { + if (s->keys[k] == key0) { cand_k = k; break; } } } + if (!cand_k && rows > 2) { + uint64_t key1 = new_keys[1]; + if (key1) { + for (int k = 1; 1 + k < rows; k++) { + if (s->keys[1 + k] == key1) { + cand_k = k; + break; + } + } + } + } if (cand_k > 0) { int total = rows - cand_k; |
