Subject: Re: bug#76538: 31.0.50; 31.0.50; 31.0.50; feature/igc: using magit-section-cycle-global (S-TAB) and magit-section-toggle (TAB) in some random ways blocks GNU Emacs.

From: Stefan Monnier <[email-masked]>
Date: Wed, 26 Feb 2025 17:53:03 -0500

> Gerd's array of markers keeps a free-list so new markers are not really
> always added to the end, but rather they're added "randomly" in the
> reverse order where markers were removed from the buffer (until reaching
> the end of this, at which point it's added to the end of the array).
> If there are enough markers in the array, anywhere that's not very-near
> the rear (or the front, depending on the order in which we scan) will
> simply never be consulted during char<->byte conversion.  🙁

Maybe we can confirm this behavior:

- in the `buf_*pos_to_*pos` code, in the `DO_MARKERS` loop, we can keep
  track of the range of indices of the markers we consult.
- then when we exit unsuccessfully and create a new cache-marker, we can
  compare the index of that cache-marker with the indices we consulted.

If the index is not within the range of indices we consulted, then this
cache-marker is most likely going to be useless (because, if nothing
else is changed, next time we need to convert at this position we simply
won't find it).

        Stefan