# Add action parameter \`comment_empty_lines\` for \`editor::ToggleComments\` \(\#63961\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/595d62863e8a6f2d8353835abe94502ee2a08139)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 595d62863e8a6f2d8353835abe94502ee2a08139

Requested commit: 595d62863e8a6f2d8353835abe94502ee2a08139

Commit: 595d62863e8a6f2d8353835abe94502ee2a08139

Tree: 101d3123c4c94b2099a780f84fa0eeaadbbbde8e

Author: Udeshya

Committer: GitHub

## Message

```
Add action parameter `comment_empty_lines` for `editor::ToggleComments` (#63961)

# 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>
```

## Parents

- [86b2cf96623a12ae3f524c3780b6bcce4443ed23](https://git.cafe/gitcafe/zed/commit/86b2cf96623a12ae3f524c3780b6bcce4443ed23?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/595d62863e8a6f2d8353835abe94502ee2a08139?format=markdown)
