Skip to content
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

Auto Generate Code to Close a Comment #69

Open
mikail-khan opened this issue Jan 22, 2020 · 5 comments
Open

Auto Generate Code to Close a Comment #69

mikail-khan opened this issue Jan 22, 2020 · 5 comments

Comments

@mikail-khan
Copy link

mikail-khan commented Jan 22, 2020

When starting a comment like

package com.foo

object Foo {

  /*    <-- starting comment here

  
  def main(args: Array[String]): Unit =
    println("Hello")

}

automatically generate the closing part of the comment like

package com.foo

object Foo {

  /*  
    my comment

  */   // <-- generate this bit so I don't have to type it in and it doesn't break the compilation of the file

  def main(args: Array[String]): Unit =
    println("Hello")

}
@tgodzik
Copy link
Contributor

tgodzik commented Jan 22, 2020

Thanks for reporting! I agree it would be very useful 😄 .

I think it would be simple to do in the on type formatting. We might need to generalize the MultilineStringFormattingProvider to also include some kind of action on comments. But this should be a really nice task for new contributions. I can give some guidance around this.

It would be nice to also include all actions from the VS Code extension or at least make sure it doesn't conflict : https://github.com/scalameta/metals-vscode/blob/master/src/extension.ts#L699

@mkiwala
Copy link

mkiwala commented Jan 22, 2020

Is metals the right place for something like this? I noticed this feature request does not include the “Describe alternatives you've considered“ that I’ve seen on other feature requests. Perhaps this feature can be configured by people who want it in their editor config.

@tgodzik
Copy link
Contributor

tgodzik commented Jan 22, 2020

@mkiwala A lot of the similar functionality is already done in VS Code extension for Metals and I think this would benefit people in general.

This could be turned of with on type formatting if some wouldn't want this functionality. Is there any scenario though it would not be good to add the end of the comment?

@mkiwala
Copy link

mkiwala commented Jan 23, 2020

Thanks for listening. I'm new to metals and vs code, but I'm looking forward to migrating away from intellij as the refactoring support in metals is being developed. Maybe I can contribute to that effort eventually.

Anyway, being new here, I didn’t initially understand that this proposed feature to automatically insert */ would be connected to a setting that I can turn off. Thank you for pointing that out.

I can see how some people would find a feature like this useful. However, especially when I reformatting existing code, I often find editor support for inserting characters — like closing parens, braces, or in this case */ — more trouble than they are worth. This is because I often have to undo the automatic additions that the editor made for me.

If this happens to me, I would just turn off “on type” formatting as you suggested.

@tgodzik
Copy link
Contributor

tgodzik commented Jan 23, 2020

I can see how some people would find a feature like this useful. However, especially when I reformatting existing code, I often find editor support for inserting characters — like closing parens, braces, or in this case */ — more trouble than they are worth. This is because I often have to undo the automatic additions that the editor made for me.

Some automatic insertions are already done by the extension in VS Code (like automatic closing brace), which cannot be turned off. For sure let us know via issues etc. if we can make it better. If something annoys or is problematic you it would be really good to know. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants