Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add context menu to search tree #46311

Merged
merged 3 commits into from
Mar 26, 2018
Merged

Add context menu to search tree #46311

merged 3 commits into from
Mar 26, 2018

Conversation

roblourens
Copy link
Member

@isidorn Would appreciate a quick review of this. The tree controller is just copied from elsewhere.

For #45063

@roblourens roblourens added the search Search widget and operation issues label Mar 22, 2018
@roblourens roblourens added this to the March 2018 milestone Mar 22, 2018
@roblourens roblourens self-assigned this Mar 22, 2018
@roblourens roblourens requested a review from isidorn March 22, 2018 05:03
@isidorn
Copy link
Contributor

isidorn commented Mar 22, 2018

Here's some feedback after trying it out:

  • We usually put the most destructive command at the end, so I would expect Dismiss to be after Replace
  • Context menu on empty area has the Dimsiss action which has not effect
  • Consider adding a "Exclude File" context menu action which would add a file to the exclude list

Regarding code I will comment directly in the code.

@@ -474,8 +474,10 @@ export abstract class AbstractSearchAndReplaceAction extends Action {

Copy link
Contributor

Choose a reason for hiding this comment

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

The proper way to do all this action command business is the following:

  • Have a command that is self contained and does the actual work
  • Use the command everywhere except Action Bar
  • For the Action Bar instatiate an Action that will only use the commandService to execute the command

That patter is cleanest and we use it all over the place (especially explorer).
If you do not want to tackle it in this PR then you can create a debt item.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll create an item to convert search Actions to commands

Copy link
Contributor

Choose a reason for hiding this comment

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

Great

@@ -354,3 +359,63 @@ export class SearchFilter implements IFilter {
return !(element instanceof FileMatch || element instanceof FolderMatch) || element.matches().length > 0;
}
}

export class SearchTreeController extends WorkbenchTreeController {
Copy link
Contributor

Choose a reason for hiding this comment

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

This works fine and we have it for instance in debug land.
However this is an old way to do this - it is a sort of bridge between comands and actions.

Since all your things could be commands this can than be much simpliar without any action items and things like that.
I suggest to look here for an inspiration on how to do it if all you guys are commands
https://github.com/Microsoft/vscode/blob/roblou/searchContextMenu/src/vs/workbench/parts/files/electron-browser/views/openEditorsView.ts#L312

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm guessing you're referring to what I do inside showContextMenu, and not the Controller itself? I see that I can use fillInActions which is simpler. But still seems action-oriented...

Copy link
Contributor

Choose a reason for hiding this comment

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

@roblourens yeah, you have to use the controller since you are a tree. However once you tackle the debt item to convert aciton to commands this might simpllify itselft.

@@ -139,6 +148,15 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
}
});

MenuRegistry.appendMenuItem(MenuId.SearchContext, {
command: {
id: Constants.ReplaceActionId,
Copy link
Contributor

Choose a reason for hiding this comment

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

It is strange that this are called ActionId when you are actually registering a command

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes... will clean this up with the above debt item.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense

@roblourens
Copy link
Member Author

We usually put the most destructive command at the end, so I would expect Dismiss to be after Replace

Agreed

Context menu on empty area has the Dimsiss action which has not effect

Fixed

Consider adding a "Exclude File" context menu action which would add a file to the exclude list

Will take this as a feature request, I can imagine lots of useful actions. I don't know if excluding an individual file is a common usecase though, especially given the X button.

@roblourens
Copy link
Member Author

How about a context menu item to "Move to panel"/"Move to sidebar"

@isidorn
Copy link
Contributor

isidorn commented Mar 26, 2018

@roblourens context menu action to Move View To Panel / Move View to Sidebar is an awesome idea. I would put it at the very end after a separtor. I would call it Move View to clarify that the whole thing will get moved actually.

@isidorn
Copy link
Contributor

isidorn commented Mar 26, 2018

@roblourens ok I think you have adressed / created issues for most of my comments so this looks good to me. Let me know if you want me to re-review or test it out. But imho the best would be to merge and create a test plan item

@roblourens roblourens merged commit 0684f8e into master Mar 26, 2018
@joaomoreno joaomoreno deleted the roblou/searchContextMenu branch April 30, 2018 08:31
@github-actions github-actions bot locked and limited conversation to collaborators Mar 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
search Search widget and operation issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants