Skip to content

Editor: Toggle Comment (Ctrl+/) does nothing #67

Description

@KrisPowers

Right now the Toggle Comment menu item (Edit > Toggle Comment) and its keyboard shortcut Ctrl+/ are both completely wired to a no-op. The menu item shows up, it responds to the keystroke, but nothing happens in the editor.

This is one of the most-used editing shortcuts in any code editor. Commenting out a block of code or a single line is something developers do constantly, and having to type the comment characters by hand every time is a real productivity hit.

What needs to happen

  • Detect the language of the current file to figure out the correct line-comment prefix (// for JS/TS/C/C++/Go/Rust/Java, # for Python/Bash/TOML/YAML, -- for Lua, etc.)
  • If the cursor is on a single line with no selection, toggle the comment on that line
  • If there is a selection spanning multiple lines, toggle comments on every line in the selection
  • "Toggle" means: if all selected lines already start with the comment prefix, remove it; otherwise add it

Files likely involved

  • app/frontend/src/components/GpuEditor.tsx -- where keybindings live and where the action handler needs to go
  • app/frontend/src/fullscreen/FullscreenIDE.tsx -- around line 799-808 where the no-op comment is
  • A language-to-comment-prefix map will need to be added somewhere

Acceptance criteria

  • Ctrl+/ on a single line toggles the line comment for the correct language
  • Ctrl+/ on a multi-line selection toggles all selected lines at once
  • Works correctly for at minimum: JS, TS, TSX, Python, C, C++, Rust, Go, Java, Bash, Lua, YAML, TOML, JSON (no-op for JSON since it has no comment syntax)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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