skip to Main Content

When I try to test out keybindings.editor.copyCommandTitle by assigning to it a key, it doesn’t seem to do anything. Is this because it does nothing?

2

Answers


  1. It literally copies the command title when you’re in the keybindings editor.

    I have it bound myself and it works fine for me. Maybe you’re not in the keybindings editor or you don’t have a keybinding focused.

    Login or Signup to reply.
  2. When in the keybindings editor and a keybinding is focused, it copies the keybinding’s command’s title to the clipboard

    KeybindingsRegistry.registerCommandAndKeybindingRule({
      id: KEYBINDINGS_EDITOR_COMMAND_COPY_COMMAND_TITLE,
      weight: KeybindingWeight.WorkbenchContrib,
      when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDING_FOCUS),
      primary: 0,
      handler: async (accessor, args: any) => {
          const editorPane = accessor.get(IEditorService).activeEditorPane;
          if (editorPane instanceof KeybindingsEditor) {
              await editorPane.copyKeybindingCommandTitle(editorPane.activeKeybindingEntry!);
          }
      }
    });
    

    ^ copied from https://github.com/microsoft/vscode/blob/111a6f72380eb66d91baf171692be2177df652e8/src/vs/workbench/contrib/preferences/browser/preferences.contribution.ts#L1101. Definition of copyKeybindingCommandTitle is in https://github.com/microsoft/vscode/blob/111a6f72380eb66d91baf171692be2177df652e8/src/vs/workbench/contrib/preferences/browser/keybindingsEditor.ts#L300 and does what its name says it does.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search