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

Support optional braces when pasting code #2816

Closed
tgodzik opened this issue Dec 9, 2020 · 2 comments
Closed

Support optional braces when pasting code #2816

tgodzik opened this issue Dec 9, 2020 · 2 comments
Assignees

Comments

@tgodzik
Copy link
Contributor

tgodzik commented Dec 9, 2020

Is your feature request related to a problem? Please describe.

Currently, when pasting code it's possible that the newly pasted code would not align well with the indented blocks. It would be best if we were able to adjust the pasted block indentation to work correctly with the enclosing block. Most likely we would need to use range formatting here.

Describe the solution you'd like
One of the solutions proposed by @odersky:

Tooling concerns: I also have observed that tools could do auto-indentation better. I believe what I would want is this:

When inserting a block of code immediately after some non-empty line, follow the indentation on that line, or indent if it is a token like = or => that opens an indentation region.

When inserting a block of code after some empty line, keep the indentation width of the original block.

There were some more alternative solutions in https://contributors.scala-lang.org/t/feedback-sought-optional-braces/4702/60

Describe alternatives you've considered
Manually format the code.

Additional context
With Scala 3's optional braces this issue becomes a much bigger problem, as wrong indentation might break the code.

Search terms:
optional braces significant indentation Scala3

@tgodzik tgodzik transferred this issue from scalameta/metals-feature-requests May 24, 2021
@dos65
Copy link
Member

dos65 commented May 24, 2021

Just want to add that alignment of pasted code might bring benefits to Scala2 writing experience too.

@tgodzik
Copy link
Contributor Author

tgodzik commented Jul 23, 2021

Closed by #2815

@tgodzik tgodzik closed this as completed Jul 23, 2021
@tgodzik tgodzik added this to the Metals v0.10.6 milestone Sep 6, 2021
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