/* Since we've exhausted overlay strings at this buffer
position, set the flag to ignore overlays until we move to
- another position. The flag is reset in
- next_element_from_buffer. */
- it->ignore_overlay_strings_at_pos_p = true;
+ another position. (The flag will be reset in
+ next_element_from_buffer.) But don't do that if the overlay
+ strings were loaded at position other than the current one,
+ which could happen if we called pop_it above, or if the
+ overlay strings were loaded by handle_invisible_prop at the
+ beginning of invisible text. */
+ if (it->overlay_strings_charpos == IT_CHARPOS (*it))
+ it->ignore_overlay_strings_at_pos_p = true;
/* If we're at the end of the buffer, record that we have
processed the overlay strings there already, so that