-
-
Notifications
You must be signed in to change notification settings - Fork 29
Adds comment toggle functionality to the editor, similar to VSCode and Zed #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Adds comment toggle functionality to the editor, similar to VSCode and Zed #129
Conversation
sonnyp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job!
src/editor.js
Outdated
| // Check for Ctrl+Shift+A (block comment toggle) | ||
| if (ctrl_pressed && shift_pressed && (keyval === Gdk.KEY_A || keyval === Gdk.KEY_a)) { | ||
| toggleBlockComment(buffer, comment_prefix || "#"); | ||
| return true; // Event handled | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what block comment is about.
This is what happens on multiple selected lines
Screencast.From.2026-01-05.19-45-45.webm
What this meant for languages like JavaScript with block comments?
/*
1
2
*/
I don't think that's useful in Commit but I would love to have it in Workbench :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove the Ctrl+Shift+A block comment functionality
| @@ -1,56 +1,54 @@ | |||
| using Gtk 4.0; | |||
|
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please leave and follow indentation style
src/ShortcutsWindow.blp
Outdated
| ShortcutsShortcut { | ||
| accelerator: "<Shift><Control>a"; | ||
| title: _("Toggle Block Comment"); | ||
| } | ||
| ShortcutsShortcut { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ShortcutsShortcut { | |
| accelerator: "<Shift><Control>a"; | |
| title: _("Toggle Block Comment"); | |
| } | |
| ShortcutsShortcut { | |
| ShortcutsShortcut { | |
| accelerator: "<Shift><Control>a"; | |
| title: _("Toggle Block Comment"); | |
| } | |
| ShortcutsShortcut { |
| const event_controller = new Gtk.EventControllerKey(); | ||
| source_view.add_controller(event_controller); | ||
|
|
||
| event_controller.connect("key-pressed", (controller, keyval, keycode, state) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't know the comment prefix, let's return
| event_controller.connect("key-pressed", (controller, keyval, keycode, state) => { | |
| event_controller.connect("key-pressed", (controller, keyval, keycode, state) => { | |
| if (!comment_prefix) { | |
| return false; // Event not handled | |
| } |
|
|
||
| // Check for Ctrl+/ (line comment toggle) | ||
| if (ctrl_pressed && !shift_pressed && keyval === Gdk.KEY_slash) { | ||
| toggleLineComment(buffer, comment_prefix || "#"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not this function job :)
| toggleLineComment(buffer, comment_prefix || "#"); | |
| toggleLineComment(buffer, comment_prefix); |
src/editor.js
Outdated
|
|
||
| // Check for Ctrl+Shift+A (block comment toggle) | ||
| if (ctrl_pressed && shift_pressed && (keyval === Gdk.KEY_A || keyval === Gdk.KEY_a)) { | ||
| toggleBlockComment(buffer, comment_prefix || "#"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
| toggleBlockComment(buffer, comment_prefix || "#"); | |
| toggleBlockComment(buffer, comment_prefix); |
|
Hey! I've removed the Ctrl+Shift+A block comment functionality as requested. The code now only has Ctrl+/ for toggling line comments, which:
It uses the existing Let me know if you need any other changes! |
Adds comment toggle functionality to the editor, similar to VSCode and Zed
Changes
Ctrl+/to toggle line commentsCtrl+Shift+Ato toggle block commentsCloses #67