Subject: bug#69259: 30.0.50; (get-pos-property 9483 'cursor-intangible) gives args-out-of-range error in folded magit buffer

From: Stefan Monnier <[email-masked]>
Date: Wed, 21 Feb 2024 09:30:06 -0500

Eli wrote:
> I think cursor-sensor is written under the assumption that the
> selected window's buffer is also the current buffer, and if so,
> magit-post-command-hook should abide by that protocol.  Stefan, am I
> right?

Not `cursor-sensor.el` in its entirety, but
`cursor-sensor-move-to-tangible` presumes that it is called with the
current-buffer already set to (window-buffer window).

StrawberryTea wrote:
> Why exactly are the window-buffer and the current-buffer different?

Good question.  AFAIK the code that runs `post-command-hook` normally
tries to avoid such situations.

> I think this has to do with persp-mode.  My guess is that when it sets
> the new window configuration, the current-buffer is not updated to the
> new window’s buffer immediately.

Could be a "bad citizen" on `post-command-hook`, indeed, which messes up
subsequent functions on the hook.  Maybe the code that runs
`post-command-hook` should be more careful to (re)set current-buffer
after each function, but it seems easier to fix the rare functions which
mess it up.

        Stefan