Skip to content

Commit

Permalink
Only highlight strings/numbers if we should.
Browse files Browse the repository at this point in the history
We didn't previously test that the flags were in-use for
highlighting strings/numbers.
  • Loading branch information
skx committed Jul 16, 2016
1 parent 1943f8a commit c197332
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions kilo.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,11 @@ void editorUpdateSyntax(erow *row) {

/* Handle "" and '' */
if (in_string) {
row->hl[i] = HL_STRING;
if ( E.syntax->flags & HL_HIGHLIGHT_STRINGS)
row->hl[i] = HL_STRING;
if (*p == '\\') {
row->hl[i+1] = HL_STRING;
if ( E.syntax->flags & HL_HIGHLIGHT_STRINGS)
row->hl[i+1] = HL_STRING;
p += 2; i += 2;
prev_sep = 0;
continue;
Expand All @@ -411,7 +413,8 @@ void editorUpdateSyntax(erow *row) {
} else {
if (*p == '"' || *p == '\'') {
in_string = *p;
row->hl[i] = HL_STRING;
if ( E.syntax->flags & HL_HIGHLIGHT_STRINGS)
row->hl[i] = HL_STRING;
p++; i++;
prev_sep = 0;
continue;
Expand All @@ -429,7 +432,8 @@ void editorUpdateSyntax(erow *row) {
/* Handle numbers */
if ((isdigit(*p) && (prev_sep || row->hl[i-1] == HL_NUMBER)) ||
(*p == '.' && i >0 && row->hl[i-1] == HL_NUMBER)) {
row->hl[i] = HL_NUMBER;
if ( E.syntax->flags & HL_HIGHLIGHT_NUMBERS)
row->hl[i] = HL_NUMBER;
p++; i++;
prev_sep = 0;
continue;
Expand Down

0 comments on commit c197332

Please sign in to comment.