Add toggle line comment command (issue #27) - #28
Merged
Conversation
Add an OPM Flow: Toggle Line Comment command that inserts or removes a '--' marker at the absolute beginning of each selected line. If every non-blank selected line is already commented the marker is removed; otherwise '-- ' is prefixed at column 0. Blank lines are left untouched. The toggle logic lives in a pure toggleLineComments() helper with unit tests. The command is exposed via the editor context menu and bound to Ctrl+/ (Cmd+/ on macOS), which VS Code resolves through the active keyboard layout.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #27.
Adds an OPM Flow: Toggle Line Comment command that comments or uncomments the selected line(s) by toggling a
--marker at the absolute beginning of each line.Behaviour
--, the marker (plus one optional following space) is removed.--is prefixed at column 0 of each non-blank line.Unlike VS Code's built-in toggle (which inserts at the indentation level), this places the marker at column 0, as requested in the issue.
Surface
opm-flow.toggleLineComment, available from the Command Palette and the editor right-click menu.Ctrl+/(Cmd+/on macOS); VS Code resolves this through the active keyboard layout, so it lands on the same physical key as the built-in comment toggle.Implementation
toggleLineComments()helper informatting.ts, with unit tests informatting.test.ts.