diff --git a/main/lib/eval/c_highlight.c b/main/lib/eval/c_highlight.c index 494ff569d..0c4347e4e 100644 --- a/main/lib/eval/c_highlight.c +++ b/main/lib/eval/c_highlight.c @@ -162,10 +162,13 @@ static void analyze(const char *src, int len_src, bool rewrite, int state) EVAL_analyze(src, len_src, state == HIGHLIGHT_COMMENT ? RT_COMMENT : RT_END, &result, rewrite); - for (n = 0; n < result.len; n++) + n = 0; + for (i = 0; i < result.len; i++) { - if (result.color[n].state == RT_END) + if (result.color[i].state == RT_END) break; + if (result.color[i].state != RT_SPACE) + n++; } GB.Array.New(&garray, GB_T_STRING, n); @@ -175,7 +178,7 @@ static void analyze(const char *src, int len_src, bool rewrite, int state) pos = 0; upos = 0; i = 0; - for (p = 0; p < n; p++) + for (p = 0; p < result.len; p++) { len = result.color[p].len; @@ -188,13 +191,13 @@ static void analyze(const char *src, int len_src, bool rewrite, int state) ulen = 0; for (l = 0; l < len; l++) ulen += get_char_length(result.str[upos + ulen]); - } - str = GB.NewString(&result.str[upos], ulen); - *((char **)GB.Array.Get(garray, i)) = str; - *((int *)GB.Array.Get(tarray, i)) = convState(result.color[p].state); - *((int *)GB.Array.Get(parray, i)) = pos; - i++; + str = GB.NewString(&result.str[upos], ulen); + *((char **)GB.Array.Get(garray, i)) = str; + *((int *)GB.Array.Get(tarray, i)) = convState(result.color[p].state); + *((int *)GB.Array.Get(parray, i)) = pos; + i++; + } pos += len; upos += ulen;