Skip to content

Fixed broken character literal highlighting (#132) #133

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nhatanh002
Copy link

@nhatanh002 nhatanh002 commented Nov 19, 2021

(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

  (See neovimhaskell#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.
@maurges
Copy link

maurges commented Jan 4, 2022

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

@nhatanh002
Copy link
Author

nhatanh002 commented Jan 7, 2022

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!

@maurges
Copy link

maurges commented Jan 8, 2022

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants