# Objective - Fixes: https://github.com/zed-industries/zed/issues/60738 - Re-iteration of https://github.com/zed-industries/zed/pull/63918 with suggested changes ## Solution - Added the parameter `comment_empty_lines` to `editor::ToggleComments` set to `false` by default. ## Testing - Tested manually. See showcase below. - Added two automated tests for the added feature. - Tested on MacOS. ## Self-Review Checklist: - [X] I've reviewed my own diff for quality, security, and reliability - [X] Unsafe blocks (if any) have justifying comments - [X] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [X] Tests cover the new/changed behavior - [X] Performance impact has been considered and is acceptable ## References The action's behavior was observed across Emacs, VSCode, and Intellij, and the corresponding keymaps were set accordingly. https://github.com/user-attachments/assets/36c1a27a-357c-468a-b56b-59ef31265329 https://github.com/user-attachments/assets/de755753-9de1-4771-980f-177810fb85ef https://github.com/user-attachments/assets/c8ecd261-2bba-4345-89f4-c1d708d8b6d2 ## Showcase Below is the screen recording of these three tests: 1. Behavior of toggling comments when `comment_empty_lines` is `true`. 2. Switching the parameter value to true after commenting a block and un-commenting the same block does not re-comment the block due to an empty line in between. 3. Menu bar item is still present, albeit it's behavior is mapped to the default value of the parameters of the bound action, instead of what is inside the keybindings file. This (bug?) was present even before. See the attached clip below. 1. https://github.com/user-attachments/assets/a9cd2a2c-437b-41a3-bd8e-c4c3a1f350cd 2. https://github.com/user-attachments/assets/4bbfb77c-9019-410e-9d0a-952d4438d2a7 3. https://github.com/user-attachments/assets/ca300e2d-2106-4bb7-865b-5d2ab89cd0f2 https://github.com/user-attachments/assets/ec1e47b6-ff99-461e-93af-af925be4d914 --- Release Notes: - Added `comment_empty_lines` parameter to `editor::ToggleComments` for multiline selections. Use `["editor::ToggleComments", {"comment_empty_lines": true}]` to comment blank lines too (default for Zed keymap now), or `["editor::ToggleComments", {"comment_empty_lines": false}]` to skip them (default for VSCode keymap). --------- Co-authored-by: Kirill Bulatov <kirill@zed.dev>
83 lines
2.6 KiB
JSON
83 lines
2.6 KiB
JSON
[
|
|
// VS Code for Linux (and Windows). See: https://code.visualstudio.com/docs/reference/default-keybindings
|
|
//
|
|
// Zed's default keymap is close to VS Code's, so this overlay only contains
|
|
// the bindings where the two diverge.
|
|
{
|
|
"context": "Editor",
|
|
"use_key_equivalents": true,
|
|
"bindings": {
|
|
"shift-alt-f": "editor::Format", // Format Document (Windows-style; Linux `ctrl-shift-i` is a Zed default already)
|
|
"ctrl-k ctrl-f": "editor::FormatSelections", // Format Selection
|
|
"shift-alt-i": "editor::SplitSelectionIntoLines", // Insert cursor at end of each line selected
|
|
"alt-z": "editor::ToggleSoftWrap", // Toggle Word Wrap
|
|
"ctrl-shift-space": "editor::ShowSignatureHelp", // Trigger Parameter Hints
|
|
"ctrl-shift-a": "editor::ToggleBlockComments", // Toggle Block Comment
|
|
"ctrl-k ctrl-c": ["editor::ToggleComments", { "advance_downwards": false, "comment_empty_lines": false }], // Add Line Comment
|
|
"ctrl-/": ["editor::ToggleComments", { "advance_downwards": false, "comment_empty_lines": false }],
|
|
"ctrl-k f12": "editor::GoToDefinitionSplit", // Open Definition to the Side
|
|
},
|
|
},
|
|
{
|
|
"context": "Editor && mode == full",
|
|
"use_key_equivalents": true,
|
|
"bindings": {
|
|
// In VS Code `ctrl-k z` is Zen Mode; the word wrap toggle moves to `alt-z`.
|
|
"ctrl-k z": "workspace::ToggleCenteredLayout",
|
|
"ctrl-i": "assistant::InlineAssist", // Inline Chat
|
|
"shift-alt-h": "call_hierarchy::ShowIncomingCalls",
|
|
},
|
|
},
|
|
{
|
|
"context": "!AcpThread > Editor && mode == full",
|
|
"use_key_equivalents": true,
|
|
"bindings": {
|
|
"ctrl-enter": "editor::NewlineBelow", // Insert Line Below (Inline Chat lives on `ctrl-i`)
|
|
},
|
|
},
|
|
{
|
|
"context": "Terminal",
|
|
"use_key_equivalents": true,
|
|
"bindings": {
|
|
"ctrl-enter": null,
|
|
},
|
|
},
|
|
{
|
|
"context": "Workspace",
|
|
"use_key_equivalents": true,
|
|
"bindings": {
|
|
"f5": "debugger::Start", // Start Debugging
|
|
"ctrl-alt-i": "agent::ToggleFocus", // Open Chat
|
|
},
|
|
},
|
|
{
|
|
"context": "Workspace && debugger_running",
|
|
"use_key_equivalents": true,
|
|
"bindings": {
|
|
"f5": null,
|
|
},
|
|
},
|
|
{
|
|
"context": "Workspace && debugger_stopped",
|
|
"use_key_equivalents": true,
|
|
"bindings": {
|
|
"f5": "debugger::Continue",
|
|
},
|
|
},
|
|
{
|
|
"context": "Workspace && debugger_session",
|
|
"use_key_equivalents": true,
|
|
"bindings": {
|
|
"f10": "debugger::StepOver",
|
|
"f11": "debugger::StepInto",
|
|
},
|
|
},
|
|
{
|
|
"context": "CallHierarchyPicker > Picker > Editor",
|
|
"use_key_equivalents": true,
|
|
"bindings": {
|
|
"shift-alt-h": "call_hierarchy::ToggleDirection",
|
|
},
|
|
},
|
|
]
|