Skip to content

Incorrect rename selection when declaration contains a generic parameter #2370

@tomwyr

Description

@tomwyr

Describe the bug
When applying a rename refactoring to a function that defines a generic type parameter and a function parameter being selected, the popup preselects an invalid portion of the text, not matching the position of the parameter. The range in the popup is shifted toward the end by the length of the generic type parameter.

Image

To Reproduce
Steps to reproduce the behavior:

  1. Declare a function with a generic type parameter and a regular parameter.
  2. Select the parameter symbol.
  3. Press F2 to rename the symbol.
  4. Observe that the selection in the popup is shifted toward the end of the line.

Expected behavior
The preselected range in the popup should match the actual position of the function parameter.

Environment

  • OS: macOS 26.1 (25B78)
  • Swift version: Apple Swift version 6.2.1 (swift-6.2.1-RELEASE)
  • Visual Studio Code version: 1.106.2 (Universal)
  • vscode-swift version: 2.14.1

Additional context
I tried to find the range-computation logic in the extension code, but it seems that the LSP provides the refactoring range somewhere around here. Since this affects the extension’s usability, I thought it would be most efficient if the issue is communicated between both projects, rather than me reporting it directly to the LSP repo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Unscreened

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions