markwatkinson / luminous

Accurate and powerful syntax highlighting library
http://luminous.asgaard.co.uk
GNU Lesser General Public License v2.1
50 stars 5 forks source link

Embedded diff highlighting needs improvement #2

Open markwatkinson opened 13 years ago

markwatkinson commented 13 years ago

the diff scanner works by isolating the actual code and then passing it down to an appropriate sub-scanner, then reassembling the diff format. The code is just one long block of added/removed/unchanged lines. This stops working in the following situation:

--- something.c
+++ something.c

  /* comment open
- comment  close */
+ comment close */

As the comment's opening/closing delimiters are essentially mismatched.

This is always going to be a potential problem as diff code fragments are always going to be incomplete, but we could try taking separately both:

1) unchanged + added 2) unchanged + removed

to form two complete-ish snippets, and then trying to merge them together so that 'unchanged' is only included in the output once. It seems a little complicated when there are multiple separated add/remove blocks, but as everything can be split intwo individual lines, it shouldn't be too hard.