Skip to content

feat: add comment toggle with Ctrl+/ #10

Description

@Jatin-Shihora

There's no quick way to comment or uncomment lines of code. You have to manually type // or # at the start of each line. When debugging, you often want to quickly comment out a block of code and uncomment it later.

What should happen

  • Ctrl+/ toggles a comment on the current line
  • If there's an active selection, it toggles comments on all selected lines
  • If the line is already commented, it removes the comment prefix. If not, it adds one
  • The comment prefix should match the current language (// for C++/Java/JS/Go/Rust, # for Python/Ruby, -- for SQL, etc.)

Things to consider

  • The current language is tracked in problem_detail.py and passed to the editor. You'll need the language info to determine the correct comment syntax
  • Comment prefixes per language are straightforward. Add a mapping in constants.py next to the existing LANG_SLUGS and LANG_EXTENSIONS maps
  • When toggling on multiple lines, check if ALL selected lines are commented before deciding to comment or uncomment. If they're mixed, comment all of them
  • This should integrate with undo/redo so Ctrl+U reverses the toggle

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions