diff options
author | Kyohei Uto <im@kyoheiu.dev> | 2022-11-01 06:16:28 +0900 |
---|---|---|
committer | Kyohei Uto <im@kyoheiu.dev> | 2022-11-01 06:16:28 +0900 |
commit | c3a62de38bdec65e295accf3654110feea1fd1e4 (patch) | |
tree | 304154091989bdcbc70c2792f5dab81b2ddcee91 /src/layout.rs | |
parent | d18fedb324178869179c1a6f3607c12868126197 (diff) |
Remove unnecessary syntex parsing
Diffstat (limited to 'src/layout.rs')
-rw-r--r-- | src/layout.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/layout.rs b/src/layout.rs index 2a7a8ce..b452923 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -151,7 +151,7 @@ impl Layout { if let Some(content) = &item.content { move_to(self.preview_start.0, BEGINNING_ROW); let mut result = vec![]; - for line in LinesWithEndings::from(content) { + for (index, line) in LinesWithEndings::from(content).enumerate() { let count = line.len() / self.preview_space.1 as usize; let mut range = h.highlight_line(line, &self.syntax_set).unwrap(); for _ in 0..=count + 1 { @@ -161,6 +161,9 @@ impl Layout { } range = ranges.1; } + if index > self.preview_space.1 as usize + item.preview_scroll { + break; + } } match self.split { Split::Vertical => { |