After debugging I discovered that the problem is not caused by
font-lock in diff-mode. The problem is in
easy-mmode-define-navigation. diff-mode uses it to navigate diff
hunks. It supports such a feature that when the user narrowed the
diff buffer, it puts narrowing back after moving to the next hunk.
But this fails when the diff buffer is narrowed automatically by
long-line-optimizations. If there is no way to distinguish whether
the narrowing is automatic by long-lines or manual by the user, this
patch fixes the problem. It works without errors, and even highlights
first 250000 characters of the long line:
Thanks.
Maybe Gregory (CC'ed) can help here and tell whether there's a better
solution.
It seems there is no better solution?