GNOME Bugzilla – Bug 748960
Ocaml highlighter does not close empty comments (**)
Last modified: 2015-05-10 18:50:05 UTC
Created attachment 302933 [details] [review] Fixes the bug. In ocaml, (**) is a closed comment but the highlighter matches the (** as the beginning of an ocamldoc section.
Review of attachment 302933 [details] [review]: Thanks for the patch. The indentation is wrong. It must normally be two spaces. ocamldoc is defined like this: <context id="ocamldoc" style-ref="ocamldoc"> <start>\(\*\*</start> <end>\*\)</end> Why (**) is matched by ocamldoc? I see how (***) matches ocamldoc, but for (**) I don't see why. Unless <start> and <end> can overlap. Can you provide a code example in tests/syntax-highlighting/ ? With an example of a normal comment, an empty comment and an ocamldoc. So we can test more easily the change.
The (** part is matched by the ocamldoc start, and then the end doesn't match so everything after it is highlighted wrong. See patch and image.
Created attachment 303119 [details] [review] Ocaml example
Created attachment 303120 [details] [review] Indentation fix
Created attachment 303121 [details] Intended highlighting for example
Review of attachment 303120 [details] [review]: Instead of adding a separate context, maybe we can use regex look-ahead in the ocaml doc definition so that it matches (** not followed by )
I don't know how to do that.
See the section "Lookahead assertions" at: https://developer.gnome.org/glib/stable/glib-regex-syntax.html (you can also see that page in devhelp, if the glib documentation is installed.)
Review of attachment 303119 [details] [review]: Looks good.
Review of attachment 303120 [details] [review]: You can also squash the indentation fix with the previous commit, so that there is only one commit. You can do that with git rebase -i, or directly with git commit --amend (if the second commit is not already created).
Created attachment 303190 [details] [review] Lookahead regex fix
Review of attachment 303190 [details] [review]: Thanks, looks good.
Commits pushed to the master branch: https://git.gnome.org/browse/gtksourceview/commit/?id=08f527445925d191ca3cf23e1984cfcc5c8d620f https://git.gnome.org/browse/gtksourceview/commit/?id=5f265ef956496c4fcf0ff8d8a322be1c2876d9b5 I just added the bug URL at the end of the commit messages.