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

Make WorkbenchActionRegistry just a forwarder #35528

Merged
merged 5 commits into from
Oct 5, 2017
Merged

Conversation

jrieken
Copy link
Member

@jrieken jrieken commented Oct 3, 2017

The goal about this is to remove IWorkbenchActionRegistry because we have commands, keybindings, and menu registries which are more flexible. However, there is weird code in places which needs to be checked first. At the end duplications like https://github.com/Microsoft/vscode/pull/35528/files#diff-b90278b8812101a32d844114fa0dc752L501 shouldn't be in our code anymore.

}
*/
this.telemetryService.publicLog('workbenchActionExecuted', { id: action.id, from: 'status bar' });
(action.run() || TPromise.as(null)).done(() => {
Copy link
Member Author

@jrieken jrieken Oct 3, 2017

Choose a reason for hiding this comment

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

@bpasero What's up with this workbenchActionExecuted-event? Is its purpose really to only report workbench-actions? So, no editor commands, no extension commands, no other commands?

Copy link
Member

Choose a reason for hiding this comment

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

@jrieken I would think that this telemetry event is logged for a) workbench actions, b) editor actions and c) contributed actions. The name is probably old and we never changed it but the data should be that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Great. In that case this was a bug.


return;
}

// Maintain old behaviour of always focusing the editor here
const activeEditor = this.editorService.getActiveEditor();
const codeEditor = getCodeEditor(activeEditor);
if (codeEditor) {
codeEditor.focus();
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure why we have it... Maybe because the command palette does that and because enablement of commands often depends on editor focus...

Copy link
Member

@bpasero bpasero Oct 3, 2017

Choose a reason for hiding this comment

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

@jrieken I think this would not be needed if all commands have a proper when clause and would simply not show up when not enabled. Related: #18517

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, the problem is that selecting something from the status bar takes/steels focus and that this means you cannot have things like 'comment line' in there. Not sure if they should find and focus an editor when executed...


return entries;
}

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 wanna get rid of these things

return null;
} else {
return title.original;
}
}
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 believe these two methods should be somewhere else

if (descriptor.label) {
// slightly weird if-check required because of
// https://github.com/Microsoft/vscode/blob/d28ace31aa147596e35adf101a27768a048c79ec/src/vs/workbench/parts/files/browser/fileActions.contribution.ts#L194
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
Copy link
Member Author

Choose a reason for hiding this comment

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

That one save-action needs clarification...

@jrieken jrieken self-assigned this Oct 3, 2017
@jrieken jrieken changed the title WIP - ActionRegistry debt Make WorkbenchActionRegistry just a forwarder Oct 4, 2017
@jrieken jrieken requested a review from sandy081 October 4, 2017 10:07
@jrieken jrieken added the debt Code quality issues label Oct 4, 2017
@jrieken
Copy link
Member Author

jrieken commented Oct 4, 2017

@bpasero @sandy081 Please review the changes

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.

@jrieken overall looks good to me but it looks like we are now reporting the workbenchActionExecuted telemetry event 2 times (once from here and once from here) when I invoke a command from the command palette.

@@ -87,7 +87,7 @@ export interface IMenuRegistry {
getMenuItems(loc: MenuId): IMenuItem[];
}

export const MenuRegistry: IMenuRegistry = new class {
export const MenuRegistry: IMenuRegistry = new class implements IMenuRegistry {
Copy link
Member

Choose a reason for hiding this comment

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

Cool, didn't know that is possible...

@jrieken
Copy link
Member Author

jrieken commented Oct 4, 2017

Thanks @bpasero. I did push two more changes that move the generic error logging out of actions and into the keybindings service. Tho, I did left the weird argument that's being passed to action.run({ from }). Do we really call actions with the 'keybinding' argument?

@bpasero
Copy link
Member

bpasero commented Oct 5, 2017

@jrieken with latest I am getting a NPE in keybindingService when running out of sources where the telemetry service is null.

I think we are changing a little bit the semantic of the workbenchActionExecuted telemetry event with these changes. Now we seem to always fire it for any command executed via keyboard and previously we would only fire it for workbench actions (not for editor actions and not for extension actions when triggered via keybinding).

Lastly, there are more uses of workbench actions that do not provide a label beyond the save action from me: here in search land.

@jrieken
Copy link
Member Author

jrieken commented Oct 5, 2017

I think we are changing a little bit the semantic of the workbenchActionExecuted telemetry event with these changes.

Yes, but are we saying that todays behaviour is correct or is it in-correct? Today we only send the event for a (random?) sub-set of commands and I don't believe that's on purpose... cc @seanmcbreen Also, the fact that we default to "triggered by keyboard" is bogus. If an extension executes a (workbench) command (via execucteCommand, as code action, or as post completion command) we will report it as triggered by keyboard which isn't correct

Lastly, there are more uses of workbench actions that do not provide a label beyond t

@roblourens What does an action without label do? Also, same question to you @bpasero? Should this just be a command?

@jrieken
Copy link
Member Author

jrieken commented Oct 5, 2017

@jrieken with latest I am getting a NPE in keybindingService when running out of sources where the telemetry service is null.

Ops, this was actually missing a commit...

@bpasero
Copy link
Member

bpasero commented Oct 5, 2017

@jrieken yes I was not saying to not report telemetry on everything, just wanted to raise that this will mean more data is collected for every time a command is triggered via keybinding.

I have changed the action to be included in command palette under the name "Save All Files", this is good to use when someone wants to save all dirty files but not any untitled files.

@jrieken
Copy link
Member Author

jrieken commented Oct 5, 2017

@sandy081 Please check the changes I made in the keybindings land

@sandy081
Copy link
Member

sandy081 commented Oct 5, 2017

@jrieken LGTM.

@jrieken jrieken merged commit 6080c16 into master Oct 5, 2017
@jrieken jrieken deleted the joh/action_debt branch October 5, 2017 11:02
@roblourens
Copy link
Member

@roblourens What does an action without label do?

I guess this is so the user can set a keybinding, but it doesn't show up in the command palette. I don't think they are useful there but if this is a problem, I can add a label.

@jrieken
Copy link
Member Author

jrieken commented Oct 6, 2017

There are better ways to achieve that. You can simply register a command (even with a label for better keybindings UI but without having it show in any menu).

@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debt Code quality issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants