Merge pull request #803 from MinusGix/line-style-fix

Check if line is at the max in line styles
This commit is contained in:
Dongdong Zhou 2022-07-18 19:13:10 +01:00 committed by GitHub
commit c1a63f69ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -9,7 +9,7 @@
Language, LossyUtf8, Node, Point, Query, QueryCaptures, QueryCursor, QueryError,
QueryMatch, Range, Tree,
};
use xi_rope::{spans::Spans, Rope};
use xi_rope::{spans::Spans, LinesMetric, Rope};
const CANCELLATION_CHECK_INTERVAL: usize = 100;
const BUFFER_HTML_RESERVE_CAPACITY: usize = 10 * 1024;
@ -967,6 +967,12 @@ pub fn line_styles(
line: usize,
styles: &Spans<Style>,
) -> Vec<LineStyle> {
let max_line = text.measure::<LinesMetric>() + 1;
if line >= max_line {
return Vec::new();
}
let start_offset = text.offset_of_line(line);
let end_offset = text.offset_of_line(line + 1);
let line_styles: Vec<LineStyle> = styles