it->face_id = (it->glyph_row->ends_at_zv_p ?
default_face->id : face->id);
- /* Display fill-column indicator if needed. */
- const int indicator_column = fill_column_indicator_column (it, 1);
-
/* Make sure our idea of current_x is in sync with the glyphs
actually in the glyph row. They might differ because
append_space_for_newline can insert one glyph without
updating current_x. */
it->current_x = it->glyph_row->used[TEXT_AREA];
+ /* The above assignment causes the code below to use a
+ non-standard semantics of it->current_x: it is measured
+ relative to the beginning of the text-area, thus disregarding
+ the window's hscroll. That is why we need to correct the
+ indicator column for the hscroll, otherwise the indicator
+ will not move together with the text as result of horizontal
+ scrolling. */
+ const int indicator_column =
+ fill_column_indicator_column (it, 1) - it->first_visible_x;
+
+ /* Display fill-column indicator if needed. */
while (it->current_x <= it->last_visible_x)
{
if (it->current_x != indicator_column)