summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-02-02 09:09:07 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-02-02 09:09:07 -0500
commit5882fac07ab1215ec4bbc859c693b28b06e6b469 (patch)
treedc4f0234126ef903768346d1d5caab2026b26b7f
parentb042a8599c47b2fd41c7eb0d22ec417ca629a986 (diff)
fix bug with non-highlighted files
-rw-r--r--buffer.c3
-rw-r--r--syntax.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/buffer.c b/buffer.c
index 00ae04d..71e0f1e 100644
--- a/buffer.c
+++ b/buffer.c
@@ -2012,7 +2012,8 @@ void buffer_render(TextBuffer *buffer, Rect r) {
gl_color_rgba(colors[COLOR_TEXT]);
}
- if (buffer->frame_latest_line_modified >= buffer->frame_earliest_line_modified) {
+ if (buffer->frame_latest_line_modified >= buffer->frame_earliest_line_modified
+ && syntax_highlighting) {
// update syntax cache
Line *earliest = &buffer->lines[buffer->frame_earliest_line_modified];
Line *latest = &buffer->lines[buffer->frame_latest_line_modified];
diff --git a/syntax.c b/syntax.c
index 56d822c..6ccfc84 100644
--- a/syntax.c
+++ b/syntax.c
@@ -220,7 +220,8 @@ static void syntax_highlight_c(SyntaxState *state_ptr, char32_t *line, u32 line_
void syntax_highlight(SyntaxState *state, Language lang, char32_t *line, u32 line_len, SyntaxCharType *char_types) {
switch (lang) {
case LANG_NONE:
- memset(char_types, 0, line_len * sizeof *char_types);
+ if (char_types)
+ memset(char_types, 0, line_len * sizeof *char_types);
break;
case LANG_C:
syntax_highlight_c(state, line, line_len, char_types);