diff options
-rw-r--r-- | main.c | 1 | ||||
-rw-r--r-- | syntax.c | 25 |
2 files changed, 21 insertions, 5 deletions
@@ -1,7 +1,6 @@ /* TODO: - fix opening file from build output (while there are any nodes open) -- fix highlighting of '\u{1023}' in Rust FUTURE FEATURES: - more tests @@ -596,14 +596,31 @@ static void syntax_highlight_rust(SyntaxState *state, const char32_t *line, u32 if (line[char_end] == '\'' && backslashes % 2 == 0) { break; } + if (backslashes % 2 == 1 && line[char_end] == 'u' + && char_end + 3 < line_len && line[char_end + 1] == '{') { + // unicode character literal e.g. '\u{1234}' + char_end += 2; // skip u{ + while (char_end + 1 < line_len) { + char_end++; + if (line[char_end] == '}') { + char_end++; + break; + } + } + if (line[char_end - 1] != '}') { + // not a unicode character + char_end = line_len; + } + break; + } + if (line[char_end] < CHAR_MAX + && backslashes % 2 == 0 + && !strchr("abcdefABCDEF0123456789", (char)line[char_end])) + break; if (line[char_end] == '\\') ++backslashes; else backslashes = 0; - if (line[char_end] < CHAR_MAX - && line[char_end - 1] != '\\' - && !strchr("abcdefABCDEF0123456789", (char)line[char_end])) - break; } if (char_end < line_len && line[char_end] == '\'') { // a character literal |