-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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 option: include command in screencast overlay #126742
Conversation
It seems very involved to figure out the keybinding for a given command on other platforms than the current. The keybindingRegistry doesn't keep the info around. I edited the PR description to not include that part of the functionality. |
@PEZ There seem to be extra commits on this PR that you did not authored. Can you clean the branch? |
1da578a
to
9a8791a
Compare
Hmm, yeah, I rebased with main, interpreting some PR instruction that way... I now force pushed a reset from before the rebase. Is that what you need, @joaomoreno ? |
@alexdima , in this PR I am currently sending along the context service to Also, the context doesn't even help. With or without passing it, |
Here's an example screencast using this feature: |
👍 to call without a context (it looks like you're passing in the global context anyways, so the behavior should be the same with or without passing it in). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few problems:
- Most commands don't show any label. Try copy text or comment line. Only the keybinding appears.
- The setting should probably be an enum instead of two settings, something like:
screencastMode.keyboardShortcutsPrefix: 'none' | 'command' | 'commandAndGroup'
- The default should not change: it should be off/
'none'
by default
@joaomoreno , thanks! I've fixed the settings. I think I need some guidance for the issue with that many commands do not show a label. I'm currently using the |
You should use the command registry instead. |
@joaomoreno , that's one of the things I've considered, but it doesn't seem to have what we need to populate the overlay: export interface ICommand {
id: string;
handler: ICommandHandler;
description?: ICommandHandlerDescription | null;
} |
I'm stuck on the issue with many built in commands not showing a label. I can say this though, that for extension contributed commands it works, and that when I create screencasts I much rather use the PR build than the regular build. Meaning to say, we're adding value as it stands. 😄 |
Isn't |
The problem I am hitting is not a lack of description. Yet. The CommanRegisitry has If I pick out one command from each registry like so: const command = shortcut?.commandId ? MenuRegistry.getCommand(shortcut.commandId) : null;
const command2 = shortcut?.commandId ? CommandsRegistry.getCommand(shortcut.commandId) : null; Logging them out shows this for some different commands:
Maybe the real fix is to have more commands registered in the MenuRegistry? But seems a bit out of scope for this PR, WDYT? |
Addressing microsoft#126713 Prepending command category. Maybe this should be a setting too?
ba4e9ec
to
534cab0
Compare
@alexdima Sorry to call you in once more, but what do you think? |
@joaomoreno See my answer to the question above ⬆️ #126742 (comment) Is there any other question that I missed? |
@alexdima @joaomoreno , if I may try to summarize what I think are the considerations: I've addressed all but one change request, which is: With the current state of the PR only commands registered in the MenuRegistry will get a command title in the screencast overlay. It seems all extension contributed commands are there, but amongst the built-in commands most are not registrered there. This raises two questions:
As to the second question, I can't see there is. If there is, I need guidance to find it. As to the first question, in my opinion the current PR brings a lot of the feature's value already, I use it often for my screencasts/demo sessions. To me it would make sense to ship this as the first take and then make separate issues for:
EDIT: Of course it can be argued that 2 and 3 are not added as settings, but rather be there, non-optional. My main point is that with these additions, this feature will rock even more than it already does. |
Commands are basically a map from a string identifier to a function to execute. So commands do not inherently come with a title in our command registry. The title is something we add for actions, which is then shown in the Command Palette or in the menus. We have hit this problem in the past, for example in the keybindings editor. There, when a title is missing, we just show the command ids: e.g. I haven't reviewed the code in this PR, but I imagine the keybindings editor needs to do something very similar (i.e. given a command id, figure out what a good title would be for it). Maybe there is potential for code reuse, I didn't dig deeper. |
This is probably why the MenuRegistry is a nice place to pick this up, since it contains I'll have a look at the shortcuts editor and see if I can reuse something. So far missing the title hasn't been the main problem, but I think it makes total sense to use the id then also in the screencast overlay. |
Progress. I just made a quick test. If i ”reuse” this function from the shortcuts editor, and use that map for grabbing labels instead of going via private getActionsLabels(): Map<string, string> {
const actionsLabels: Map<string, string> = new Map<string, string>();
EditorExtensionsRegistry.getEditorActions().forEach(editorAction => actionsLabels.set(editorAction.id, editorAction.label));
for (const menuItem of MenuRegistry.getMenuItems(MenuId.CommandPalette)) {
if (isIMenuItem(menuItem)) {
const title = typeof menuItem.command.title === 'string' ? menuItem.command.title : menuItem.command.title.value;
const category = menuItem.command.category ? typeof menuItem.command.category === 'string' ? menuItem.command.category : menuItem.command.category.value : undefined;
actionsLabels.set(menuItem.command.id, category ? `${category}: ${title}` : title);
}
}
return actionsLabels;
} Should I go this way? (I don't think we'll win so much by refactoring the function out of the shortcuts editor, because we have slightly different requirements in the screencast overlay as the user options are designed right now. I think using a copy and adapting it makes sense, but it is not my codebase. 😄) |
👍 I would leave it as is and suggest we wait for @joaomoreno 's feedback. |
If we're happy with the results, let's just merge it as is. One nit though. Currently when a command description is found, this appears as such: And now that I see it in action, I would actually prefer we generalize the setting. Instead of
What do you think? |
I love the suggested options. The only consideration here is that we currently do not catch enough commands. So the |
@joaomoreno I have been running with the generalized settings a while now and I think they work great. I choose to default to As a
|
Thanks! 🍻 |
Is this in the Insiders Build yet? I can't find the setting to test it. Version: 1.62.0-insider (user setup) |
@ArturoDent, not yet. We're currently stabilizing so we can release stable. It will be in Insiders closer to the end of this week. |
This PR fixes #126713
Adding a setting
screencastMode.showShortcutCommandTitles
for including the command title in the Screencast Mode overlay. The setting defaults totrue
. When it is active the keybindings are:Also adding a setting
screencastMode.showShortcutCommandTitlesWithCategory
which will prepend the command category when enabled.NB:
keybindingService.lookupKeybinding(commandId)
is used to display the full shortcut chord. This method/function has a bug making it sometimes pick up the wrong keybinding, if different keybindings are configured for the shortcut for different operating systems. I think it might be the same root cause as for #126306.