Subject: bug#61215: 29.0.60; font-lock broken in diff-mode with long lines

From: Juri Linkov <[email-masked]>
Date: Fri, 03 Feb 2023 09:53:57 +0200

>> 1. Set debug-on-error and backtrace-on-redisplay-error to t
>> 2. Create a commit with some diff hunks in a prog mode at the beginning,
>>    and a single-line 1MB file added at the end;
>> 3. From *vc-change-log* type `d' on that commit that opens *vc-diff* buffer
>> 4. Scroll the *vc-diff* buffer
>>
>> It displays an error in the *Warning* buffer:
>>
>>   ⛔ Warning (error): Error in a redisplay Lisp hook.  See buffer *Redisplay_trace*
>
> Can you reproduce this easily?

Once you create such a commit, it's easy to reproduce this on it.

> If so, does the patch below help?

Unfortunately, no.  Still such a backtrace:

Error: args-out-of-range (#<buffer *vc-diff*> 2000 1906)
  mapbacktrace(#f(compiled-function (evald func args flags) #<bytecode -0x12357049b0517812>))
  debug-early-backtrace()
  debug-early(error (args-out-of-range #<buffer *vc-diff*> 2000 1906))
  buffer-substring-no-properties(2000 1906)
  (let* ((hunk (buffer-substring-no-properties (max beg (point-min)) (min end (point-max)))) ...
  diff-syntax-fontify-hunk(2000 250945 nil)
  diff-syntax-fontify(2000 250945)
  #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_39>(2000 250945)
  diff--iterate-hunks(10000 #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_39>)
  diff--font-lock-syntax(10000)
  font-lock-fontify-keywords-region(1527 10000 nil)
  font-lock-default-fontify-region(1527 3027 nil)
  font-lock-fontify-region(1527 3027)
  #f(compiled-function (fun) #<bytecode -0x156e2446868bfa03>)(font-lock-fontify-region)
  run-hook-wrapped(#f(compiled-function (fun) #<bytecode -0x156e2446868bfa03>) font-lock-fontify-region)
  jit-lock--run-functions(1527 3027)
  jit-lock-fontify-now(1527 3027)
  jit-lock-function(1527)
  redisplay_internal\ \(C\ function\)()