mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-25 20:41:49 +03:00
Regex: Only allow SyntaxCharacter and - to be escaped in a character class
Letting any character to be escaped is error prone as it looks like \l could mean [:lower:] (as it used to with boost) when it only means literal l. Fix the haskell.kak file as well. Fixes #1945
This commit is contained in:
parent
6fdb9db5d9
commit
b27d4afa8d
@ -39,7 +39,7 @@ add-highlighter shared/haskell/code regex (?<!')\b(case|do|else|if|in|let|mdo|of
|
||||
|
||||
# matches uppercase identifiers: Monad Control.Monad
|
||||
# not non-space separated dot: Just.const
|
||||
add-highlighter shared/haskell/code regex \b([A-Z]['\w]*\.)*[A-Z]['\w]*(?!['\w])(?![.\l]) 0:variable
|
||||
add-highlighter shared/haskell/code regex \b([A-Z]['\w]*\.)*[A-Z]['\w]*(?!['\w])(?![.a-z]) 0:variable
|
||||
|
||||
# matches infix identifier: `mod` `Apa._T'M`
|
||||
add-highlighter shared/haskell/code regex `\b([A-Z]['\w]*\.)*[\w]['\w]*` 0:operator
|
||||
|
@ -429,24 +429,21 @@ private:
|
||||
if (cp == '\\')
|
||||
{
|
||||
auto it = find_if(character_class_escapes,
|
||||
[cp = *m_pos](auto& t) { return t.cp == cp; });
|
||||
[cp = *m_pos](auto&& t) { return t.cp == cp; });
|
||||
if (it != std::end(character_class_escapes))
|
||||
{
|
||||
character_class.ctypes |= it->ctype;
|
||||
++m_pos;
|
||||
continue;
|
||||
}
|
||||
else // its just an escaped character
|
||||
else // its an escaped character
|
||||
{
|
||||
cp = *m_pos++;
|
||||
for (auto& control : control_escapes)
|
||||
{
|
||||
if (control.name == cp)
|
||||
{
|
||||
cp = control.value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
auto it = find_if(control_escapes, [cp](auto&& t) { return t.name == cp; });
|
||||
if (it != std::end(control_escapes))
|
||||
cp = it->value;
|
||||
else if (not contains("^$\\.*+?()[]{}|-", cp)) // SyntaxCharacter and -
|
||||
parse_error(format("unknown character class escape '{}'", cp));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user