Fix stack overflow in reporting

This commit is contained in:
Richard Feldman 2022-07-27 15:22:21 -04:00
parent fa5bd442f8
commit c2865e39ff
No known key found for this signature in database
GPG key ID: 7E4127D1E4241798

View file

@ -633,8 +633,13 @@ impl<'a> RocDocAllocator<'a> {
// If the outer region takes more than 1 full screen (~60 lines), only show the inner region
if region.end().line.saturating_sub(region.start().line) > 60 {
// If the inner region contains the outer region (or if they are the same),
// attempting this will recurse forever, so don't do that! Instead, give up and
// accept that this report will take up more than 1 full screen.
if !sub_region.contains(&region) {
return self.region_with_subregion(sub_region, sub_region);
}
}
// if true, the final line of the snippet will be some ^^^ that point to the region where
// the problem is. Otherwise, the snippet will have a > on the lines that are in the region