Subject: Re: bug#23079: 25.0.92; Movement commands leave cursor in invisible line

From: Stefan Monnier <[email-masked]>
Date: Tue, 22 Mar 2016 21:59:38 -0400

>       (let ((inhibit-read-only t)
>             (deactivate-mark nil)
>             (selection (magit-region-sections)))
>         (mapc #'delete-overlay magit-section-highlight-overlays)
>         (setq magit-section-unhighlight-sections
>               magit-section-highlighted-sections
>               magit-section-highlighted-sections nil)
>         (unless (eq section magit-root-section)
>           (run-hook-with-args-until-success
>            'magit-section-highlight-hook section selection))
>         (--each magit-section-unhighlight-sections
>           (run-hook-with-args-until-success
>            'magit-section-unhighlight-hook it selection))
>         (restore-buffer-modified-p nil)

Hmm... what kind of buffer modifications might happen in here?
I think this might be the problem: point-adjustment is only applied after
"movement commands" and is disabled if the buffer was modified during
the course of the command (including post-command-hook).
[ This is mostly due to the simplistic way we keep track of the
  "previous state", which we can't trust if the buffer was modified.  ]

> This function doesn't move point, but it somehow interferes with point
> adjustment in another way.

It's difficult to adjust point without risking adverse effects in corner
cases (typically problems like "repeated C-n gets stuck" or "forward-foo
moves backward"), so point-adjustment is conservative to try and make
sure it's only done when we're sure it's "safe".

        Stefan