Add setting to prevent closing the pinned tab when using middle click (fix #115734)#188592
Add setting to prevent closing the pinned tab when using middle click (fix #115734)#188592bpasero merged 12 commits intomicrosoft:mainfrom
Conversation
|
@bpasero Hi, I have two questions: |
|
@weartist I would have a setting which then we can turn on by default to see how many users are upset. If there are no complaints I am also easy to remove the setting again and make it the default behaviour. I would think the change should only be where we close from mouse middle click: For the "Open Editors" view: For tabs: For no tabs: |
Understand, i rushed XD, and thank you for the code point! |
|
I simply completed the feature and tested it, hoping it worked fine @bpasero |
bpasero
left a comment
There was a problem hiding this comment.
The method is actually called isSticky in the internal API, I know its misleading, but isPinned is for a different feature (preview tabs).
Should the setting be more specific to mention that it is for mouse middle click only? We already prevent closing a tab by keybinding irrespective of the setting.
That is, can I replace isPinned: isSticky: and I'll go and change the description again |
|
Yes, can be replaced with |
|
@weartist I had a thought: what if the setting changes back to the original name you had in mind and becomes an enumeration that allows to fully control the behaviour for closing:
This would be a good way to keep the setting around even for the future to let people fully control the close behaviour and then we can think about a reasonable default? |
@bpasero Does your mention of ' never close for mouse' include right-clicking the tab and selecting 'close' from the pop-up menu? I think it's well that this feature can be fully controlled through settings. For me, I need to prevent the keyboard from closing tabs, but I still want to be able to close them by right-clicking with the mouse, otherwise I'd have to cancel pinned and click again every time. |
|
Yeah I was suggesting to target only these 2 cases:
But not other actions, such as the menu. |
|
In this case, does mouse closing only include clicking the mouse middle button? I will try to write a simple version. |
|
will start tomorrow. Tonight I will think about whether there are some other cases to consider XD |
|
Yeah, so I meant middle-mouse-click. |
|
@bpasero I want to abstract the logic that judges whether to block closing into a method, something like 'isPinned', but I didn't find a good place for it. The current code has some repetition and verbosity |
bpasero
left a comment
There was a problem hiding this comment.
Yeah some code-reuse might be good, for example from a method in src/vs/workbench/common/editor.ts. I feel the method could accept the editor in question and then either the configuration service or the part options to return if the editor should close based on a context such as mouse or key.
|
have reworked the relevant code, but have not tested it yet |
|
After a simple test, the function looks fine |
|
@weartist I did a review and pushed changes, can you please test out everything works as expected? |
sure, thanks! I'll start testing after reading it, this is my favorite part to learn in order for me to improve haha |
|
@bpasero It's run as excepted |
Fix #115734