From 514530c19a51dbc1786e27e7449bf5574d539e88 Mon Sep 17 00:00:00 2001 From: Benjamin Kampmann Date: Mon, 9 Jan 2023 18:54:24 +0100 Subject: [PATCH] fix(sliding-sync): ensure last index is also invalidated Index ranges are inclusive, but our loop would stop one short. This particuarly tricky when the selective view is moved, as we didn't properly invalidate all items. --- crates/matrix-sdk/src/sliding_sync.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/matrix-sdk/src/sliding_sync.rs b/crates/matrix-sdk/src/sliding_sync.rs index 226d46620..0f526b118 100644 --- a/crates/matrix-sdk/src/sliding_sync.rs +++ b/crates/matrix-sdk/src/sliding_sync.rs @@ -1419,7 +1419,9 @@ impl SlidingSyncView { )); } - while pos < end { + // ranges are inclusive up to the last index. e.g. `[0, 10]`; `[0, 0]`. + // ensure we pick them all up + while pos <= end { if pos as usize >= max_len { break; // how does this happen? }