Subject: bug#51558: Long mode-line-compact breaks tab-line tabs

From: Eli Zaretskii <[email-masked]>
Date: Tue, 02 Nov 2021 15:02:37 +0200

> From: Juri Linkov <[email-masked]>
> Date: Mon, 01 Nov 2021 21:59:42 +0200
> 
> 0. emacs -Q
> 1. (setq mode-line-compact 'long)
> 2. (global-tab-line-mode)
> 3. Visit more buffers in the same window
> 4. Click on a non-first tab on the tab-line
> 5. It always selects the first tab only
> 
> The click event returns a string that contains all tabs,
> whereas with the default value of mode-line-compact
> the event correctly contains only one tab's string.
> 
> I don't know why mode-line-compact affects the tab-line,
> but maybe it should have a condition to not apply to the tab-line?

I think it's indeed a bug that mode-line-compact affects anything but
the mode line.  Does the patch below give good results?

diff --git a/src/xdisp.c b/src/xdisp.c
index 436153b..c05e7ed 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -25592,7 +25592,8 @@ display_mode_line (struct window *w, enum face_id face_id, Lisp_Object format)
   push_kboard (FRAME_KBOARD (it.f));
   record_unwind_save_match_data ();
 
-  if (NILP (Vmode_line_compact))
+  if (NILP (Vmode_line_compact)
+      || face_id == HEADER_LINE_FACE_ID || face_id == TAB_LINE_FACE_ID)
     {
       mode_line_target = MODE_LINE_DISPLAY;
       display_mode_element (&it, 0, 0, 0, format, Qnil, false);