Subject: bug#66678: 30.0.50; Tabs close erratically in text terminal

From: Juri Linkov <[email-masked]>
Date: Sun, 22 Oct 2023 20:42:14 +0300

close 66678 29.1.90
thanks

> - Create a new tab by clicking on "+" on the tab bar.
>   Now you should have two tabs named `*scratch*'
> - Click on the first (leftmost) tab right after the second asterisk.
>
> Expected behavior: Leftmost tab is selected.
> Actual behavior: Leftmost tab is closed.
>
> I traced the issue to `tab-bar-auto-width' function which — I think — is
> used to pad a tab text with spaces to make it have a uniform width
> within the tab bar.  The function erroneously copies 'close-tab text
> property from the close button text (tab-bar-close-button) and positions
> it right after the buffer name, causing the said behavior.
>
> The attached patch fixes the immediate issue, but I doubt if it is
> sufficient, given that there is similar close tab-related logic elsewhere
> in the code.  Another workaround is to set `tab-bar-close-button' to one
> character string "x" instead of " x".

Thank you for finding this subtle bug and fixing it.
The space before "x" was intended to give more space to click
on the close button, i.e. for more wider clicking area.
So better to keep the 'close-tab' text property on the space.
This means that your patch is the right way to fix this.
Now it's pushed to the emacs-29 branch as well as separately
to master to avoid merge conflicts.