From b351dbbcbb199cf1b6135130e679a83198b23a29 Mon Sep 17 00:00:00 2001 From: mars Date: Wed, 12 Apr 2023 18:24:06 -0400 Subject: [PATCH] Faster syntax highlighting with a style stack --- src/buffer.rs | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/buffer.rs b/src/buffer.rs index 4e94f65..95926ab 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -25,7 +25,7 @@ use crossterm::{cursor, ExecutableCommand, QueueableCommand}; use parking_lot::Mutex; use ropey::Rope; use syntect::easy::ScopeRangeIterator; -use syntect::parsing::{ParseState, Scope, ScopeStack, SyntaxSet}; +use syntect::parsing::{BasicScopeStackOp, ParseState, Scope, ScopeStack, SyntaxSet}; use crate::theme::{Style, StyleStore}; use crate::{Cursor, Direction}; @@ -150,6 +150,8 @@ impl Buffer { let mut parser = self.parser.clone(); let mut line_buf = String::new(); let mut stack = ScopeStack::new(); + let mut style_stack = Vec::