Clip points coming from language server

This avoids panicking in Zed if the points they give us are invalid.

Co-Authored-By: Max Brunsfeld <max@zed.dev>
This commit is contained in:
Antonio Scandurra 2021-10-28 19:02:26 +02:00
parent d12387b753
commit ce8741977b
2 changed files with 8 additions and 2 deletions

View file

@ -711,7 +711,9 @@ impl Buffer {
end = last_edit_new_end + (end - last_edit_old_end);
}
Some((start..end, (severity, diagnostic.message)))
let range =
content.clip_point(start, Bias::Left)..content.clip_point(end, Bias::Right);
Some((range, (severity, diagnostic.message)))
}),
)
};