ziglang / zig-mode

Zig mode for Emacs
GNU General Public License v3.0
163 stars 54 forks source link

string highlighting doesn't stop if end quote is preceded by an escaped backslash #47

Closed travv0 closed 4 months ago

travv0 commented 3 years ago

An example from std.os.windows, everything after the following line is highlighted as a string because it sees the end quote as escaped:

const prefix_u8 = "\\DosDevices\\";
endragor commented 3 years ago

Possibly related: if a multi-line string literal ends with an empty line, everything after that line is highlighted as a string. Example:

const test_str =
    \\I need the empty line
    \\
;
endragor commented 3 years ago

Ah, you already fixed that. So nevermind :)

travv0 commented 3 years ago

Yeah, I got that fixed but my emacs knowledge wasn't enough for me to figure this one out. It seems like the function currently used for highlighting multiline strings might be overkill since you'd think a simple regex would do the trick, but it seems like there's some sort of "priority" to what gets highlighted so when I tried to highlight based on a regex match, it only matched strings that didn't have highlighted keywords in them.