Skip to content

rename operation corrupts unrelated source code #76439

@weltkante

Description

@weltkante

Version Used:

VS 2022 17.13.0 Preview 2.0

Steps to Reproduce:

start with pasting

public class Program
{
    public void Main()
    {
        int count = 10, n = 15;

        for (int metaInput = -(count + 2); metaInput < n; metaInput++)
        {
            for (int input2 = -(count + 2); input2 < n; input2++)
            {
            }
        }
    }
}

and place the cursor on one of the metaInput references. Then rename to input1 with F2.

Expected Behavior:

Renaming doesn't touch unrelated code

Actual Behavior:

The inner for loop gets corrupted in various ways depending on which occurence of the variable you tried to rename:

for (int input2 = -(count + 2); ); input2 < n; input2++)
for (int input2 = -(count count + 2); input2 < n; input2++)
for (int (int input2 = -(count + 2); input2 < n; input2++)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions