On 07/02/2012 09:33 PM, Eli Zaretskii wrote: > Shouldn't we test w->window_end_valid for being non-zero, before we > trust the value of w->window_end_vpos? Zero for a vertical position > is perfectly valid, so if i is zero, you can err here. The core idea is to have window_end_vpos (and window_end_pos) equal to -1 for just created window (i.e. pointer returned by make_window). For such a window, window_end_valid is always 0, and passing such a window to main redisplay routines is an error (so there are 4 debugging checks commented with "Just initialized windows should not pass here"). If the window is completely initialized, window_end_vpos may be 0 and window_end_valid may be 0 or 1. > If the "invalid" value is going to be -1, then why did you initialize > with zero above? See above. > Bother: doesn't the comparison with w->buffer test for a specific > buffer, rather than just non-nil value? The corresponding assignment, > viz.: > >> if (accurate_p) >> { >> - w->window_end_valid = w->buffer; >> + w->window_end_valid = 1; >> w->update_mode_line = 0; >> } > > seems to handle the case when the display is "accurate". Perhaps use > a different value, like 2, for this situation? I tried a lot, but never hits the situation where window buffer was changed on the way from mark_window_display_accurate_1 to note_mouse_highlight (buffer text may be changed, of course). So I suppose that w->window_end_valid = w->buffer is just a synonym for w->window_end_valid = Qt. Dmitry