question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Auto-insert `//` for additional non-dartdoc comment lines

See original GitHub issue

https://github.com/Dart-Code/Dart-Code/issues/147 requested automatically inserting /// when pressing Enter on a dartdoc comment line, but could we do the same for non-dartdoc comment lines? IMO we should just preserve whatever the current comment marker is.

I vaguely recall seeing some discussion about this before, but if it happened, I seem unable to find it now. Is it intentionally not done because there’s some expectation that users might be annoyed if they write a comment, hit Enter, and then expect to write code? If that’s a concern, is it possible to have an option, or maybe make, say, Enter/Shift+Enter do different things?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
DanTupcommented, Apr 12, 2021

Yes, I like that - and I think it’s reasonable to have it enabled always (as long as you haven’t set the setting to none).

I’ve added this line to the end of the setting because I also couldn’t come up with a better way, but I’m open to changing it before it ships if someone has a better idea. Thanks!

Screenshot 2021-04-12 at 17 36 29

So with the default (tripleSlash), it won’t add // to the end of a comment, but it will when there is text after the caret. It’ll try to do the right thing with spaces too - so if you press <enter> with a space after the caret it will avoid inserting an additional one after the slashes.

Apr-12-2021 17-39-08

1reaction
DanTupcommented, Apr 1, 2021

With the former, I’m in the mode of writing documentation (or at least larger) comments. In contrast, with `//, I’m usually writing a single-line comment or I’ve just commented out a block of code.

That’s fair. I’m a bit on the fence - the new behaviour surprised me a few times (because I’m used to it not happening), but a few times was helpful to.

Please do file a new issue, and I’ll add a setting. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add an Option for "Auto-insert `//` for additional non-dartdoc ...
In contrast, with // , I'm usually writing a single-line comment or I've just commented out a block of code. In either case,...
Read more >
Effective Dart: Documentation
We all know code should be self-documenting and not all comments are helpful. ... Add a blank line after the first sentence to...
Read more >
Dart on VsCode: How to enable comment continuation on ...
I checked this question about the same feature for Rust language: How to configure VSCode to auto insert comment chars on multi line...
Read more >
dartdoc | Dart Package - Pub.dev
A non-interactive HTML documentation generator for Dart source code.
Read more >
Dartdoc comment style - Google Groups
The reason I ask is that my text editor does not handle '///' comments correctly ... adding an command line option to dartfmt...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found