microsoft / microsoft/vscode-cpptools

Renaming (F2) parameter in function declaration in header file doesn't rename it in defintion

Open
#9,746 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug Feature: Rename Language Service Visual Studio
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
  • OS and Version: Windows 10
  • VS Code Version: 1.70.2
  • C/C++ Extension Version: 1.11.5
Bug Summary and Steps to Reproduce

When renaming (F2) a parameter in a function declaration in a header file, the parameter in the function definition in the source file that includes the header file is not renamed and it is also not listed in the refactor preview. The same applies vice versa.

However, if the function declaration is placed in the source file, the parameter in the function definition is listed in the refactor preview if the parameter in the declaration is renamed and vice versa.

Expected behavior

The parameter in the function definition should be listed in the refactor preview for selection if the parameter in the declaration is renamed and vice versa, regardless of whether the declaration is placed in the source or in a included header file.

Code sample and Logs
// test.c

#include "test.h"

void foo(int arg)
{
  return;
}


// test.h

void foo(int arg);
Screenshots

Refactor preview when renaming a parameter in the declaration when it is placed in the source file:

image

Refactor preview when renaming a parameter in the definition when it is placed in the source file:

image

After renaming a parameter in the declaration when it is placed in the included header file (no refactor preview):

image

After renaming a parameter in the definition when it is placed in the included header file (no refactor preview):

image

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the rename with the issue's test.c and test.h example using F2 in VS Code, then trace the refactor-preview handling for declarations and definitions across an included header. Done means renaming either parameter lists the matching parameter in the other file for selection in the preview.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.