Subject: bug#36858: 27.0.50; display bugs with display-fill-column-indicator-mode

From: Ergus <[email-masked]>
Date: Fri, 9 Aug 2019 00:29:14 +0200

On Thu, Aug 08, 2019 at 08:33:38PM +0300, Eli Zaretskii wrote:
>> Date: Thu, 8 Aug 2019 09:17:58 +0200
>> From: Ergus <[email-masked]>
>> Cc: [email-masked], [email-masked]
>>
>> After tying this solution I proposed yesterday to add the indicator also
>> for the latest line (call extend_face_to_end_of_line for a no empty line
>> without \n too) I get it working perfectly fine only in the tui
>> interface.
>>
>> In gui it just doesn't work. But it seems that the issue is not due to
>> the condition:
>>
>> if (!get_next_display_element (it));
>>
>> because when I add a test glyph unconditionally there; it is not printed
>> in the screen, but when I add a message to stdout it is.
>>
>> For sure I am missing something here, but what?
>>
>> Is it possible that some optimization in the gui glue code stops
>> printing glyphs OR that some later code hides the extra glyphs?
>
>I don't think I understand what you tried well enough to answer the
>question.  Can you show a patch relative to the current master?
>
See the attachement

>Thanks.
diff --git a/src/xdisp.c b/src/xdisp.c
index 7338d2b7d4..a39f2e0bd9 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -21837,17 +21837,17 @@ display_line (struct it *it, int cursor_vpos)
 	 buffer reached.  */
       if (!get_next_display_element (it))
 	{
-	  bool row_has_glyphs = false;
+	  const bool row_has_glyphs = row_text_area_empty (row);
 	  /* Maybe add a space at the end of this line that is used to
 	     display the cursor there under X.  Set the charpos of the
 	     first glyph of blank lines not corresponding to any text
 	     to -1.  */
 	  if (IT_OVERFLOW_NEWLINE_INTO_FRINGE (it))
 	    row->exact_window_width_line_p = true;
-	  else if ((append_space_for_newline (it, true)
+	  else if (row_has_glyphs
+	           ||(append_space_for_newline (it, true)
 		    && row->used[TEXT_AREA] == 1)
-		   || row->used[TEXT_AREA] == 0
-		   || (row_has_glyphs = row_text_area_empty (row)))
+		   || row->used[TEXT_AREA] == 0)
 	    {
 	      row->glyphs[TEXT_AREA]->charpos = -1;
 	      /* Don't reset the displays_text_p flag if we are
@@ -21878,7 +21878,8 @@ display_line (struct it *it, int cursor_vpos)
 	     background color.  */
 	  if (row->reversed_p
 	      || lookup_basic_face (it->w, it->f, DEFAULT_FACE_ID)
-              != DEFAULT_FACE_ID)
+              != DEFAULT_FACE_ID
+	      || !row_has_glyphs)
 	    extend_face_to_end_of_line (it);
 	  break;
 	}