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

Scala 3: rename broken in several ways #6795

Open
kubukoz opened this issue Sep 21, 2024 · 0 comments
Open

Scala 3: rename broken in several ways #6795

kubukoz opened this issue Sep 21, 2024 · 0 comments

Comments

@kubukoz
Copy link
Contributor

kubukoz commented Sep 21, 2024

Describe the bug

I can split these up into separate issues if necessary, but they seem related so I'll start by posting them together.

Example code:

object main {
  def myMethod(
      s1: String,
      s2: String,
      s3: String,
      s4: String,
  ) = s1 ++ s2 ++ s3 ++ s4

  val word1 = "hello"
  val word2 = "world"

  myMethod(
    word1,
    word2,
    s3 = word1,
    s4 = word2,
  )
}

Issue 1: renaming a val at its definition site doesn't get reflected in function parameters.

To reproduce:

  1. Put cursor here: val wo<CURSOR>rd1 = "hello"
  2. Rename to e.g. aaaaaa

Actual result:

val aaaaaa = "hello"
val word2 = "world"

myMethod(
  word1,
  word2,
  s3 = word1,
  s4 = word2,
)

Expected:

val aaaaaa = "hello"
val word2 = "world"

myMethod(
  aaaaaa,
  word2,
  s3 = aaaaaa,
  s4 = word2,
)

Issue 2: Same as above, but try renaming in the middle of the word1 occurrences in the call to myMethod.

Issue 3: renaming a final parameter with a trailing comma thinks the comma is part of the name (and doesn't update anything)

To reproduce:

  1. Put cursor here: s4 = wo<CURSOR>rd2,
  2. Run a rename. The pop-up will show word2, as the "old" name
  3. Rename to anything
  4. Notice nothing happening

Expected behavior: the comma isn't shown as part of the old name. Renaming in that position works (both the definition and the call-site).

Relevant LSP trace:

[Trace - 04:40:27 PM] Sending response 'textDocument/prepareRename - (22)'. Processing request took 1054ms
Result: {
  "start": {
    "line": 15,
    "character": 9
  },
  "end": {
    "line": 15,
    "character": 15
  }
}

Expected behavior

Described above in each case.

Operating system

macOS

Editor/Extension

VS Code

Version of Metals

v1.3.5

Extra context or search terms

No response

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

1 participant