Skip to content

Conversation

@Kalmaegi
Copy link
Contributor

@Kalmaegi Kalmaegi commented Jul 23, 2023

Fix #115734

@Kalmaegi
Copy link
Contributor Author

@bpasero Hi, I have two questions:
Do we need to make settings for this obstacle?
If I add judgment for pinned here, the scope may be a little larger. Do we need to move the judgment to where the mouse middle button is clicked to determine, in order to reduce the impact scope of this obstacle?
Thanks!

@bpasero
Copy link
Member

bpasero commented Jul 24, 2023

@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:

e.element.group.closeEditor(e.element.editor, { preserveFocus: true });

For tabs:

this.closeEditorAction.run({ groupId: this.group.id, editorIndex: index });

For no tabs:

this.group.closeEditor(this.group.activeEditor);

@Kalmaegi
Copy link
Contributor Author

@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:

e.element.group.closeEditor(e.element.editor, { preserveFocus: true });

For tabs:

this.closeEditorAction.run({ groupId: this.group.id, editorIndex: index });

For no tabs:

this.group.closeEditor(this.group.activeEditor);

Understand, i rushed XD, and thank you for the code point!

@bpasero bpasero marked this pull request as draft July 24, 2023 06:56
@Kalmaegi
Copy link
Contributor Author

I simply completed the feature and tested it, hoping it worked fine @bpasero

Copy link
Member

@bpasero bpasero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Kalmaegi
Copy link
Contributor Author

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 with isSticky? I did confuse the two judgments a bit, I found that the two were almost identical, then I found their implementation, but still not possible to confirm whether they are equal haha

isPinned:

isPinned(editorOrIndex: EditorInput | number): boolean {

isSticky:
isPinned(editorOrIndex: EditorInput | number): boolean {

and I'll go and change the description again

@bpasero
Copy link
Member

bpasero commented Jul 25, 2023

Yes, can be replaced with isSticky.

@bpasero bpasero added this to the August 2023 milestone Jul 25, 2023
@bpasero bpasero marked this pull request as ready for review July 25, 2023 07:07
@bpasero
Copy link
Member

bpasero commented Jul 25, 2023

@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:

  • one option to never close for neither keyboard nor mouse
  • one option to never close for keyboard
  • one option to never close for mouse
  • one option to always allow to close

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?

@Kalmaegi
Copy link
Contributor Author

@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:

  • one option to never close for neither keyboard nor mouse
  • one option to never close for keyboard
  • one option to never close for mouse
  • one option to always allow to close

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.

@bpasero
Copy link
Member

bpasero commented Jul 25, 2023

Yeah I was suggesting to target only these 2 cases:

  • closing by keybinding
  • closing by mouse

But not other actions, such as the menu.

@Kalmaegi
Copy link
Contributor Author

In this case, does mouse closing only include clicking the mouse middle button? I will try to write a simple version.

@Kalmaegi
Copy link
Contributor Author

will start tomorrow. Tonight I will think about whether there are some other cases to consider XD

@bpasero
Copy link
Member

bpasero commented Jul 25, 2023

Yeah, so I meant middle-mouse-click.

@Kalmaegi
Copy link
Contributor Author

@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

Copy link
Member

@bpasero bpasero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Kalmaegi Kalmaegi requested a review from bpasero July 26, 2023 09:33
@Kalmaegi
Copy link
Contributor Author

have reworked the relevant code, but have not tested it yet

@Kalmaegi
Copy link
Contributor Author

After a simple test, the function looks fine

@bpasero
Copy link
Member

bpasero commented Jul 27, 2023

@weartist I did a review and pushed changes, can you please test out everything works as expected?

@Kalmaegi
Copy link
Contributor Author

@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

@Kalmaegi
Copy link
Contributor Author

@bpasero It's run as excepted

@bpasero bpasero changed the title Fix #115734 Jul 28, 2023
@bpasero bpasero enabled auto-merge (squash) July 28, 2023 07:26
@bpasero bpasero merged commit 55b75c5 into microsoft:main Jul 28, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Sep 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

5 participants