Fix Locator::from_index

Enhance language::tests::test_random_collaborators so that it checks buffer invariants.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld 2022-01-05 17:58:24 -08:00
parent e5faaeb2f2
commit f9f75e98f8
4 changed files with 46 additions and 34 deletions

View file

@ -20,7 +20,7 @@ impl Locator {
}
pub fn from_index(ix: usize, count: usize) -> Self {
let id = ((ix as u128 * u64::MAX as u128) / count as u128) as u64;
let id = (1 + ix as u64) * (u64::MAX / (count as u64 + 2));
Self(smallvec![id])
}