Skip to content

Add a command that cycles between no comment, double-slash, triple-slash #4255

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

Closed
jamesderlin opened this issue Nov 8, 2022 · 4 comments
Closed
Labels
in editor Relates to code editing or language features is enhancement
Milestone

Comments

@jamesderlin
Copy link

If I press Ctrl+/ (Toggle Line Comment) on a Dartdoc line, currently the line gets transformed from:

/// Dartdoc line

to:

/ Dartdoc line

Even though it'd be asymmetric with adding a comment, I think it'd be nice if uncommenting removed either // or ///. This would be particularly useful if I'm writing a Dartdoc comment, press Enter, which automatically adds /// to the next line, but don't actually want the next line to be a Dartdoc comment.

I'm using v3.52.1 of the Dart VS Code extension.

@DanTup
Copy link
Member

DanTup commented Nov 8, 2022

Unfortunately "Toggle Line Comment" is entirely a VS Code feature that's driven by a static language configuration we provide it that only supports a single set of comment markers. I've an open issue with VS Code about extending this here (which you can 👍!):

microsoft/vscode#64659

We have added a Toggle Dartdoc Comment command that does similar for triple-slashes in the meantime (although now I'm wondering if there's value in a single command that just goes through all three states - no comment, double slash, triple slash, so you don't need two keybindings 🤔).

@DanTup DanTup added this to the Backlog milestone Nov 8, 2022
@DanTup DanTup added blocked on vs code / lsp / dap Requires a change in VS Code to progress in editor Relates to code editing or language features labels Nov 8, 2022
@jamesderlin
Copy link
Author

jamesderlin commented Nov 8, 2022

I'm wondering if there's value in a single command that just goes through all three states - no comment, double slash, triple slash, so you don't need two keybindings

I think a command that cycles through those three states would be great.

@DanTup DanTup removed the blocked on vs code / lsp / dap Requires a change in VS Code to progress label Nov 8, 2022
@DanTup DanTup changed the title Toggle Line Comment could be smarter about uncommenting Dartdoc lines Add a command that cycles between no comment, double-slash, triple-slash Nov 8, 2022
@DanTup DanTup modified the milestones: Backlog, v3.54.0 Nov 8, 2022
@DanTup
Copy link
Member

DanTup commented Nov 8, 2022

Yeah, not sure why I didn't do that previously. This command is already doing the work to figure out what the current comments across the selection look like. I'll re-purpose this issue to add a command that cycles through them. Thanks!

@DanTup DanTup closed this as completed in 637e7b2 Nov 10, 2022
@DanTup
Copy link
Member

DanTup commented Nov 10, 2022

I've done this, and it works fine, though I'm now wondering whether cycling through three is the best option or whether it should just be a replacement for Toggle Line Comment (eg. only ever adds double slashes), it is just smarter about removing the triple slashes (which was your original request).

I'm wondering if there's much call to add triple-slashes to existing uncommented/double-slashed code or whether it's mostly just used for commenting/uncommenting chunks with double-slashes.

Thoughts? (we could ofc add both, but giving descriptive names to them might be harder... "Cycle Line Comment" vs "Toggle Line Comment"?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in editor Relates to code editing or language features is enhancement
Projects
None yet
Development

No branches or pull requests

2 participants