Open thenger opened 1 year ago
I think something like this will ultimately be supported via configurable mouse bindings (see issue #1553). The idea being that you could choose what action you want a mouse button to perform in a particular context. In this case, you'd bind the middle mouse button to the Close Tab action when the mouse is located over a tab.
This operation is interesting, though, because you would assumedly want to close the tab that you're hovering hover, rather than the active tab. That's something that'll need to be accounted for in the binding format which I don't think has been considered before.
I agree about the configurability aspect, but I personally feel like middle click should by default close the hovered tab even if the X button is hidden. Or was that done intentionally?
It's, ah, an implementation detail. The only way to suppress the X button was to mark the tab as non-closeable. We should fix it more comprehensively... 😝
Oh I didn't realise this was already the default behavior when the close button is visible, since I don't have a middle mouse button. If that's the case, I agree it should continue to work when the button is hidden. However, I still think it's worth referencing this issue in #1553 if we eventually plan to support this as a configurable binding, because it is a bit different from other actions.
To enable the ability to close tabs with a middle click when the close ("x") button is hidden in Microsoft Terminal, you can modify the Terminal settings by adding a custom key binding. Here's an example of how you can achieve this:
Open Microsoft Terminal and click on the downward-facing arrow located at the top-right corner of the window. This will open the drop-down menu.
Select "Settings" from the drop-down menu. This will open the settings file in your default text editor.
In the settings file, locate the "actions"
section. This section contains an array of key bindings and actions.
Add the following code snippet to the "actions"
array:
{
"command": "closeTab",
"keys": [
"middleButton"
]
}
This code snippet defines a new key binding for the middle button, which will trigger the "closeTab"
action.
Save the settings file and close the text editor.
Restart Microsoft Terminal for the changes to take effect.
After performing these steps, you should be able to close tabs by middle-clicking on them, even when the close ("x") button is hidden in Microsoft Terminal.
This doesn't work for me. Well at least it closes the "settings" tab with the middle click.
What version are you testing this in ?
edit : my version:
Windows Terminal Version: 1.17.11461.0
on w11
It was in milestone 1.19 but it looks like it got lost ?
On 2023-06-07 it was added to "Terminal v1.19". On 2023-08-17 it was removed from "Terminal v1.19" and added to "Backlog" and label "Help Wanted" added. So, ...
Description of the new feature/enhancement
Problem
Can't close tab using mouse middle click.
Consequence
This is a consequence of #3335 (hide close button (x) on tabs).
Possible workaround not perfect
I think keyboard shortcuts are not a solution when you browse tabs with mouse.
Feature result
When close button is hidden, user can close tab using the mouse middle click