If I terminate any double-quoted string with \\, Kakoune throws a parse error regarding an unterminated string, as if I had ended it with just \ (which would then escape the double quote).
echo "foo\\x" # works
echo "foo\\" # parse error
echo "\\" # parse error
Similarly, putting \\ before a " escapes it just as putting merely \ does:
echo "foo\\"bar" # this works, but shouldn't
As near as I can tell, it's parsing for the end of the string separately from how it parses escapes, and when it finds a " it simply looks one character back to see if it's a \ and if so, treats the quote as escaped, even if that \ had itself been escaped.
It occurs to me that with this fixed, there's one subtlety, which is how is "%"foo"" parsed? The two options are:
I'd lean towards the first simply because, with either approach, "%" produces an error, but the error produced from approach 1 makes more sense than complaining about an unterminated string (because it tells the user that the % is trying to introduce a string expansion, rather than confusing them by saying there's no string terminator when it looks like there is one).
Regarding "%"foo"", it should do the first option, we parse the content on the "..." later on, so the existence of expands in the string content has no impact on how we parse it, we just look for the first non escaped closer.
The other behaviour seems to be an error, I'll take a stab at fixing that when I get a bit of time.
Argh, I took a look, its pretty easy to fix, but it brings us into escaping hell, as \\ now needs to be written \\\\ in "..." and '...' strings. Thankfully we have % strings that do not support escaping at all.