diff options
author | pommicket <pommicket@gmail.com> | 2024-07-17 23:12:30 -0700 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2024-07-17 23:12:30 -0700 |
commit | bf27c55563994a634b76b6f78afcf538a8b89839 (patch) | |
tree | 126a7eff8516aedccbac9d8533a54124648d477b | |
parent | dd6dcaec09426e786f5265fcb08dea283cb63fc0 (diff) |
fix highlighting of '\u{1023}' in Rust
-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 |