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

Rename on a variable renames variables in a following spec #1180

Closed
michalmuskala opened this issue Jan 25, 2022 · 1 comment · Fixed by #1183
Closed

Rename on a variable renames variables in a following spec #1180

michalmuskala opened this issue Jan 25, 2022 · 1 comment · Fixed by #1183
Labels
bug Something isn't working

Comments

@michalmuskala
Copy link
Contributor

Describe the bug
Given this code:

foo(A) -> A.

-spec bar(A :: integer()) -> integer().
bar(A) -> A.

Using the "Rename" command with text "B" on either of the A variables in foo produces:

foo(B) -> B.

-spec bar(B :: integer()) -> integer().
bar(A) -> A.

Expected behavior

It should not touch the spec and produce:

foo(B) -> B.

-spec bar(A :: integer()) -> integer().
bar(A) -> A.

Context

  • erlang_ls version (tag/sha): Last release (Erlang LS (in erlang_ls), version: 0.21.2, OTP version: 24)
  • Editor used: VS Code
@michalmuskala michalmuskala added the bug Something isn't working label Jan 25, 2022
@gomoripeti
Copy link
Contributor

thanks Michal for the report. Indeed the heuristic to find the scope of the variable needs to be improved. (Currently it assumes the scope is a function clause and to find the end it takes the next function clause after the variable https://github.com/erlang-ls/erlang_ls/blob/main/apps/els_lsp/src/els_rename_provider.erl#L231)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants