Skip to content

Commit

Permalink
Update DESIGN.md
Browse files Browse the repository at this point in the history
  • Loading branch information
tshino committed Nov 28, 2021
1 parent 55ab29b commit a9ebec3
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,26 @@ So we end up defining a bunch of wrapper keybindings to capture the whole set of

A wrapper keybinding associates a particular combination of `key` and `when` with the `kb-macro.wrap` command with `args` parameter that specifies the target command to be invoked. The `kb-macro.wrap` command executes the target command. This indirect execution makes it possible to capture the command that has been triggered by user's keystrokes.

We use the wrapper command only when the macro recording is ongoing. So we add the `kb-macro.recording` context to the wrapper keybindings.
We use the wrapper command only when the macro recording is ongoing. So we add the `kb-macro.recording` context to every wrapper keybinding.

Why don't we use the wrapper keybindings always to simplify things? Because we want to keep the original behavior of each command for the keybindings as much as possible. It is not clear but the indirect execution may not be perfectly transparent.

## Default wrapper keybindings

This extension defines a large set of keybindins to capture all the default keyboard shortcuts of VS Code.
This extension defines a large set of keybindings to capture all the default keyboard shortcuts of VS Code.

The list of default wrapper keybindings is defined in the `package.json` of this extension. The list is automatically generated by a script `generator/gen-wrapper.js`. The script takes JSON files that contain the default keybindings of VS Code for Windows, Linux, and macOS, and combines all the keybindings in them with additional context such as `isWindows`, `isLinux`, or `isMac` as needed, and convert them to wrappers and write them into `keybindings` section of the `package.json`.
The list of default wrapper keybindings is defined in the `package.json` of this extension. The list is automatically generated by a script `generator/gen_wrapper.js`. The script takes JSON files where each one contains the default keybindings of VS Code for Windows, Linux, and macOS respectively, and combines all the keybindings in them with additional context such as `isWindows`, `isLinux`, or `isMac` as needed, and convert them to wrappers and write them into `keybindings` section of the `package.json`.

The script also performs some optimization work to reduce the amount of wrapper keybinding rules.

| Related files | |
| ------------- | --- |
| `generator/default-keybindings-win.json` | the default keybindings of VS Code for Windows |
| `generator/default-keybindings-linux.json` | the default keybindings of VS Code for Linux |
| `generator/default-keybindings-mac.json` | the default keybindings of VS Code for macOS |
| `generator/gen_wrapperjs` | a script to generate default wrapper keybindings and write them in `package.json` |
| `generator/verify_wrapperjs` | a script to verify the output of `gen_wrapper.js` |

## Capturing typed characters

On VS Code, typed characters in text editors are treated differently than other keystrokes. We don't put every possible character in the keybindings. When you type characters in a text editor, for each character, the `type` build-in command is invoked internally. The `type` command performs inserting each character into the document.
Expand Down

0 comments on commit a9ebec3

Please sign in to comment.