Skip to content

Keyboard shortcut for "Toggle Line Comment" (Cmd+/) does not work inside code chunks in Visual Mode #987

@HuaKaifang

Description

@HuaKaifang

Bug description

In Positron, when working in Visual Mode within a .qmd or .Rmd file, the keyboard shortcut for toggling line comments (Cmd + / on macOS or Ctrl + / on Windows) does not work when the cursor is inside a code chunk (e.g., {python} or {r}).

However, it works perfectly fine when switching back to Source Mode.

In RStudio, the comment shortcut works seamlessly inside code chunks even in Visual Mode. As an RStudio user migrating to Positron, this feels like a slight regression in the user experience. It would be highly appreciated if the Visual Editor could pass the comment shortcut down to the underlying code cell.

Steps to reproduce
Open a .qmd or .Rmd document in Positron.
Switch to Visual Mode.
Insert or find a code chunk (e.g., {python}).
Place the cursor on a line of code inside the chunk.
Press Cmd + / (macOS) or Ctrl + / (Windows).
Expected behavior
The current line of code inside the chunk should be commented out (e.g., adding # at the beginning of the line), just like it does in RStudio's Visual Mode or Positron's Source Mode.

Actual behavior
Nothing happens. The shortcut seems to be intercepted or ignored by the Visual Editor.

Environment
OS: macOS (or Windows, please specify)
Positron Version: (You can find this in Positron menu -> About Positron)

Steps to reproduce

No response

Actual behavior

No response

Expected behavior

No response

Your environment

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions