zed icon indicating copy to clipboard operation
zed copied to clipboard

Document `["editor::ToggleComments", {"advance_downwards": true}]`

Open probably-neb opened this issue 11 months ago • 1 comments

Currently this feature is not very discoverable.

We should have some documentation and examples in the default keymap for this so people can know it exists!

We could make it the default, however, that could potentially be an annoying change for existing users.

probably-neb avatar Apr 03 '25 00:04 probably-neb

Stumbled upon advance_downwards when remapping ToggleComments and so far can't figure out what it does 😅 when I set it to true my keybinding doesn't seem to do anything 🤔

CanRau avatar Jun 04 '25 15:06 CanRau

The intended behavior is that with "advance_downwards" set to true, when you toggle a comment on a line we advance your cursor down one line making it chainable. Could you share your keybind definition so I could try and figure out what's going wrong? It works fine for me when I use the exact syntax in the issue title

probably-neb avatar Jun 12 '25 08:06 probably-neb

Sorry for the late reply

This one right?

// Zed keymap
//
// For information on binding keys, see the Zed
// documentation: https://zed.dev/docs/key-bindings
//
// To see the default key bindings run `zed: open default keymap`
// from the command palette.
[
	{
		"context": "Workspace",
		"bindings": {
			// "shift shift": "file_finder::Toggle"
			"alt-cmd-v": "workspace::ToggleVimMode"
		}
	},
	{
		"context": "Editor",
		"bindings": {
			// "j k": ["workspace::SendKeystrokes", "escape"]
			"ctrl-tab": "editor::Outdent",
			"shift-tab": "tab_switcher::Toggle",
			"cmd-shift-7": ["editor::ToggleComments", { "advance_downwards": false }]
		}
	},

	{
		"context": "Workspace",
		"bindings": {
			"cmd-1": ["pane::ActivateItem", 0],
			"cmd-2": ["pane::ActivateItem", 1],
			"cmd-3": ["pane::ActivateItem", 2],
			"cmd-4": ["pane::ActivateItem", 3],
			"cmd-5": ["pane::ActivateItem", 4],
			"cmd-6": ["pane::ActivateItem", 5],
			"cmd-7": ["pane::ActivateItem", 6],
			"cmd-8": ["pane::ActivateItem", 7],
			"cmd-9": ["pane::ActivateItem", 8],
			"cmd-0": "pane::ActivateLastItem"
		}
	},
	{
		"context": "Editor",
		"bindings": {
			"cmd-1": ["pane::ActivateItem", 0],
			"cmd-2": ["pane::ActivateItem", 1],
			"cmd-3": ["pane::ActivateItem", 2],
			"cmd-4": ["pane::ActivateItem", 3],
			"cmd-5": ["pane::ActivateItem", 4],
			"cmd-6": ["pane::ActivateItem", 5],
			"cmd-7": ["pane::ActivateItem", 6],
			"cmd-8": ["pane::ActivateItem", 7],
			"cmd-9": ["pane::ActivateItem", 8],
			"cmd-0": "pane::ActivateLastItem"
		}
	}
]

CanRau avatar Jun 25 '25 01:06 CanRau

Hmm, this seems to be a bug. When I try your binding (cmd-shift-7) with the key context view open (dev: open key context view) when I enter your binding the key context view shows the entered binding as cmd-&. Fortunately, changing the binding from cmd-shift-7 to cmd-& fixes it for me on an English layout.

probably-neb avatar Jun 30 '25 16:06 probably-neb