haskell-vim icon indicating copy to clipboard operation
haskell-vim copied to clipboard

Fixed broken character literal highlighting (#132)

Open nhatanh002 opened this issue 3 years ago • 3 comments

(See #132)

When a character literal contains a "region" start pattern ('(','[','{','"'), everything after the start pattern is interpreted as a contained region, and consequently breaks syntax highlighting. After further investigation, the regex used to match character literal is actually incorrect according to the Haskell 2010 language specification (https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-200002.6), which means most valid character literals aren't highlighted at all, and the \u<code> pattern while not being a legal character in Haskell, is correctly highlighted.

This commit tries to remedy the above issues.

Like I explained in #132, this is the current state of affairs: 2021-11-20T01:47:43,282991015+07:00 2021-11-20T01:49:22,307889855+07:00

This is what this commit does instead, the escaped characters are highlighted as SpecialChar: 2021-11-20T01:46:05,713059110+07:00 2021-11-20T01:50:24,921294298+07:00

nhatanh002 avatar Nov 19 '21 19:11 nhatanh002

Your changes break the highlighting of ' in the middle and end of the word, so that now foldl' starts a char region: Screenshot_20220104_165355

And also it breaks 'this and ''This

maurges avatar Jan 04 '22 09:01 maurges

Sorry for the late response, I got caught up with my works lately so I haven't been (and won't be, for the time being) able to look into this :( I just tried to port how other languages' syntax plugin do char regions to Haskell, but I did overlook identifiers in Haskell can have ' in them, and I didn't find any obvious way to address that, and of course real life caught up. If you could try to find a solution for the time being, that would be much appreciated!

nhatanh002 avatar Jan 07 '22 08:01 nhatanh002

Absolutely no problems. It's not even my repo..

You can check the issue thread where I posted my findings on the matter. Meanwhile I've been using this sequence: \k\@123<! in front of every '. This is not ideal as it misses some corner cases with multiple quotes, so my reasearch continues.

maurges avatar Jan 08 '22 08:01 maurges