Fix detecting as include when using < and remove debug lines

This commit is contained in:
Night Kaly 2024-11-12 02:10:36 +00:00
parent 50bbd18f7b
commit 2a0d604c7e
Signed by: night0721
SSH key fingerprint: SHA256:B/hgVwUoBpx5vdNsXl9w8XwZljA9766uk6T4ubZp5HM

10
vip.c
View file

@ -701,7 +701,7 @@ int is_separator(int c)
int is_symbol(int c) int is_symbol(int c)
{ {
return strchr("+-/*=~%><", c) != NULL; return strchr("+-/*=~%><:?", c) != NULL;
} }
void update_highlight(row_t *row) void update_highlight(row_t *row)
@ -786,7 +786,8 @@ void update_highlight(row_t *row)
prev_sep = 1; prev_sep = 1;
continue; continue;
} else { } else {
if (c == '<') { if (c == '<' && (row->render[i-1] == 'e' || (row->render[i-1] == ' ' &&
row->render[i-2] == 'e'))) {
in_include = 1; in_include = 1;
row->hl[i] = STRING; row->hl[i] = STRING;
i++; i++;
@ -812,8 +813,7 @@ void update_highlight(row_t *row)
continue; continue;
} }
if (c == '*' || c == '&' || c == '=' || c == '+' || c == '|' || c == '!' || if (is_symbol(c)) {
c == '<' || c == '>') {
row->hl[i] = SYMBOL; row->hl[i] = SYMBOL;
prev_sep = 1; prev_sep = 1;
i++; i++;
@ -844,11 +844,9 @@ void update_highlight(row_t *row)
char word[128]; char word[128];
int word_len = 0; int word_len = 0;
while (!is_separator(row->render[i])) { while (!is_separator(row->render[i])) {
printf("i: %d, row->render[i]: %c\n", i, row->render[i]);
word[word_len++] = row->render[i++]; word[word_len++] = row->render[i++];
} }
word[word_len] = '\0'; word[word_len] = '\0';
printf("word: %s\n", word);
if (row->render[i] == '(') { if (row->render[i] == '(') {
memset(&row->hl[i - word_len], KW_FN, word_len); memset(&row->hl[i - word_len], KW_FN, word_len);
prev_sep = 1; prev_sep = 1;