]> git.mdlowis.com Git - projs/tide.git/commitdiff
Added a cap to scan distance for syntax highlighting
authorMichael D. Lowis <mike@mdlowis.com>
Fri, 16 Jun 2017 00:16:35 +0000 (20:16 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Fri, 16 Jun 2017 00:16:35 +0000 (20:16 -0400)
config.h
lib/view.c

index a4d6544d89da5e2407181413b1bbb1aef4cdee74..aa3450b3623f9caee50b9ad64f316102e0e38cf9 100644 (file)
--- a/config.h
+++ b/config.h
@@ -19,22 +19,23 @@ extern int CLR_NormalText, CLR_GutterText, CLR_SelectedText, CLR_TagsBkg,
 /* General Config
  ******************************************************************************/
 enum {
-    Width          = 640,     /* default window width */
-    Height         = 480,     /* default window height */
-    ExpandTabs     = 1,       /* Tabs will be expanded to spaces */
-    TabWidth       = 4,       /* maximum number of spaces used to represent a tab */
-    ScrollLines    = 4,       /* number of lines to scroll by for mouse wheel scrolling */
-    BufSize        = 8192,    /* default buffer size */
-    EventTimeout   = 50,      /* Maximum blocking wait time for events */
-    TrimOnSave     = 1,       /* Enable trimming of trailing whitespace on save */
-    DefaultCRLF    = 0,       /* Default to Unix line endings */
-    DefaultCharset = UTF_8,   /* We assume UTF-8 because nothing else matters */
-    FontCacheSize  = 16,      /* Maximum number of fonts allowed in the font cache */
-    LineSpacing    = LNSPACE, /* Set the vertical spacing between lines */
-    DblClickTime   = 250,     /* Millisecond time for detecting double clicks */
-    RulePosition   = 80,      /* Column in which the vertical ruler appears */
-    CopyIndent     = 1,       /* New lines will inherit the indent of the preceding line */
-    LineNumbers    = 1,       /* Enable line numbers by default or not */
+    Width           = 640,     /* default window width */
+    Height          = 480,     /* default window height */
+    ExpandTabs      = 1,       /* Tabs will be expanded to spaces */
+    TabWidth        = 4,       /* maximum number of spaces used to represent a tab */
+    ScrollLines     = 4,       /* number of lines to scroll by for mouse wheel scrolling */
+    BufSize         = 8192,    /* default buffer size */
+    EventTimeout    = 50,      /* Maximum blocking wait time for events */
+    TrimOnSave      = 1,       /* Enable trimming of trailing whitespace on save */
+    DefaultCRLF     = 0,       /* Default to Unix line endings */
+    DefaultCharset  = UTF_8,   /* We assume UTF-8 because nothing else matters */
+    FontCacheSize   = 16,      /* Maximum number of fonts allowed in the font cache */
+    LineSpacing     = LNSPACE, /* Set the vertical spacing between lines */
+    DblClickTime    = 250,     /* Millisecond time for detecting double clicks */
+    RulePosition    = 80,      /* Column in which the vertical ruler appears */
+    CopyIndent      = 1,       /* New lines will inherit the indent of the preceding line */
+    LineNumbers     = 1,       /* Enable line numbers by default or not */
+    MaxScanDistance = 16384,   /* Maximum distance to scan before visible lines for syntax higlighting */
 };
 
 #ifdef INCLUDE_DEFS
index 89872658c6713eed9a9af8fc00483a23bf9a3a15..ff7013f758dc2dba7760c27b5b8f1c94ecaa729f 100644 (file)
@@ -103,12 +103,13 @@ void view_update(View* view, size_t* csrx, size_t* csry) {
         view_scrollto(view, csr);
     /* locate the cursor if visible */
     find_cursor(view, csrx, csry);
-
     /* synchronize, scan for, and apply highlighted regions */
     size_t first = view->rows[0]->off,
            last  = view->rows[view->nrows-1]->off + view->rows[view->nrows-1]->rlen;
     view->spans = colors_rewind(view->spans, first);
-    first = (view->spans ? view->spans->end : 0);
+    size_t start = (view->spans ? view->spans->end : 0);
+    if (first-start > MaxScanDistance)
+        start = first - MaxScanDistance;
     view->spans = colors_scan(view->syntax, view->spans, &(view->buffer), first, last+1);
     apply_colors(view);
 }