microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.65k stars 8.32k forks source link

Ability to close tabs with mouse middle click when close ("x") button is hidden (#3335) #15517

Open thenger opened 1 year ago

thenger commented 1 year ago

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

j4james commented 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.

lhecker commented 1 year ago

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?

DHowett commented 1 year ago

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... 😝

j4james commented 1 year ago

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.

rifat01mahmud commented 1 year ago

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:

  1. 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.

  2. Select "Settings" from the drop-down menu. This will open the settings file in your default text editor.

  3. In the settings file, locate the "actions" section. This section contains an array of key bindings and actions.

  4. 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.

  1. Save the settings file and close the text editor.

  2. 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.

thenger commented 1 year ago

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

thenger commented 3 months ago

It was in milestone 1.19 but it looks like it got lost ?

Vampire commented 3 months ago

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, ...