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

Extract code action should support fewer baces syntax #7138

Open
KacperFKorban opened this issue Jan 18, 2025 · 0 comments
Open

Extract code action should support fewer baces syntax #7138

KacperFKorban opened this issue Jan 18, 2025 · 0 comments
Labels
bug Something that is making a piece of functionality unusable code action Related to LSP code actions Scala 3 Generic ticket relating to Scala 3 spree

Comments

@KacperFKorban
Copy link
Collaborator

When using the Extract code action on the following code that uses fewer braces syntax:

//> using scala 3

import scala.util.Try

def main =
  val x = Try:
    So@@me(new Exception)

the result is the following (obviously incorrect and non-compiling) code:

//> using scala 3

import scala.util.Try

def main =
  val newValue = :
    Some(new Exception)
  val x = Try(newValue)

This seems to suggest that Extract code action doesn't support the fewer braces syntax and just inlines the entire raw content of the Apply.

Expected behaviour:

I would expect for the result of the code action to correctly recognize that the fewer braces syntax was used and produce correct code (without the dangling :) i.e.

//> using scala 3

import scala.util.Try

def main =
  val newValue =
    Some(new Exception)
  val x = Try(newValue)

Operating system:
Linux

Java version:
17.0.13

Editor/extension:
Visual Studio Code v1.96.2

Metals version:
1.4.2

Extra context or search terms:

scala3 extract code action fewer braces

Workspace information:

  • Scala versions: 3.6.3
  • Build tools: 0. scala-cli
  • Build servers:
    0. scala-cli v1.5.4
  • All build tools in workspace:
@KacperFKorban KacperFKorban added bug Something that is making a piece of functionality unusable code action Related to LSP code actions Scala 3 Generic ticket relating to Scala 3 labels Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is making a piece of functionality unusable code action Related to LSP code actions Scala 3 Generic ticket relating to Scala 3 spree
Projects
None yet
Development

No branches or pull requests

2 participants