Prevent aborts in line-move-visual
* src/indent.c (line_number_display_width): Avoid assertion violations in init_iterator when the window's buffer was temporarily switched without updating window-start. (Bug#29326)
This commit is contained in:
parent
648c128b5f
commit
90add182a4
1 changed files with 11 additions and 6 deletions
17
src/indent.c
17
src/indent.c
|
@ -1959,21 +1959,26 @@ line_number_display_width (struct window *w, int *width, int *pixel_width)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
struct it it;
|
struct it it;
|
||||||
struct text_pos wstart;
|
struct text_pos startpos;
|
||||||
bool saved_restriction = false;
|
bool saved_restriction = false;
|
||||||
ptrdiff_t count = SPECPDL_INDEX ();
|
ptrdiff_t count = SPECPDL_INDEX ();
|
||||||
SET_TEXT_POS_FROM_MARKER (wstart, w->start);
|
SET_TEXT_POS_FROM_MARKER (startpos, w->start);
|
||||||
void *itdata = bidi_shelve_cache ();
|
void *itdata = bidi_shelve_cache ();
|
||||||
/* We must start from window's start point, but it could be
|
/* We want to start from window's start point, but it could be
|
||||||
outside the accessible region. */
|
outside the accessible region, in which case we widen the
|
||||||
if (wstart.charpos < BEGV || wstart.charpos > ZV)
|
buffer temporarily. It could even be beyond the buffer's end
|
||||||
|
(Org mode's display of source code snippets is known to cause
|
||||||
|
that), in which case we just punt and start from point instead. */
|
||||||
|
if (startpos.charpos > Z)
|
||||||
|
SET_TEXT_POS (startpos, PT, PT_BYTE);
|
||||||
|
if (startpos.charpos < BEGV || startpos.charpos > ZV)
|
||||||
{
|
{
|
||||||
record_unwind_protect (save_restriction_restore,
|
record_unwind_protect (save_restriction_restore,
|
||||||
save_restriction_save ());
|
save_restriction_save ());
|
||||||
Fwiden ();
|
Fwiden ();
|
||||||
saved_restriction = true;
|
saved_restriction = true;
|
||||||
}
|
}
|
||||||
start_display (&it, w, wstart);
|
start_display (&it, w, startpos);
|
||||||
/* The call to move_it_by_lines below will not generate a line
|
/* The call to move_it_by_lines below will not generate a line
|
||||||
number if the first line shown in the window is hscrolled
|
number if the first line shown in the window is hscrolled
|
||||||
such that all of its display elements are out of view. So we
|
such that all of its display elements are out of view. So we
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue