修正前のコードでは startIndex に対しては下限値、endIndex に対しては上限値
に対するチェックを行っているが、startIndex, endIndex ともに tabInfo.AllCount を
越えている場合に、endIndex のみ上限値である tabInfo.AllCount - 1 に変更される。
これにより、startIndex と endIndex の大小関係が逆転してしまうことで
ArgumentException が発生する状態となっていた。
https://osdn.net/ticket/browse.php?group_id=6526&tid=36684
if (tabInfo.AllCount == 0)
return;
+ // インデックスを 0...(tabInfo.AllCount - 1) の範囲内にする
+ int FilterRange(int index)
+ => Math.Max(Math.Min(index, tabInfo.AllCount - 1), 0);
+
// キャッシュ要求(要求範囲±30を作成)
- startIndex = Math.Max(startIndex - 30, 0);
- endIndex = Math.Min(endIndex + 30, tabInfo.AllCount - 1);
+ startIndex = FilterRange(startIndex - 30);
+ endIndex = FilterRange(endIndex + 30);
var cacheLength = endIndex - startIndex + 1;