microsoft / microsoft/vscode-cpptools

Rename Symbol includes unrelated files from include path

Open
#4,766 1 comment 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Feature: Find All References Feature: Rename Language Service verified Works in VS
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Type: LanguageService

Describe the bug

  • OS and Version: Arch Linux Manjaro
  • VS Code Version: 1.41.0 Microsoft Branded from AUR
  • C/C++ Extension Version: latest 0.26.2
  • Short Description: Rename Symbol command can put out-of-scope, non-related files from the include path into the Confirmed Rename (Pending Rename) section. NOT tested if it actually performs the rename, but if it did, it would break other programs relying on it.

To Reproduce

  1. Open brand new folder (no include paths, cpp_properties, etc. needed) and create main.cpp with:
struct Tag {};
int main() { return 0; }
  1. Rename Symbol on Tag (probably works on other common names as well)
  2. Provided name was common enough, VSCode will default to modifying files in the include path. For Tag, it will attempt to replace in /usr/include/google/protobuf/parse_context.h:
template <typename Tag, typename T>
PROTOBUF_MUST_USE_RESULT const char* ReadRepeatedFixed(const char* ptr, Tag expected_tag, RepeatedField<T>* out);

Note in this instance it would probably not break anything as it is a local name.

Expected behavior

VSCode C/C++ Rename detects that occurance is unrelated to the local definition and puts it into "Candidates for Rename" at best.

Screenshots

Screenshot_2019-12-19_00-25-02
(In context of project, but tested with provided example as well)

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

Start by reproducing the Rename Symbol behavior with the provided main.cpp example on the reported VS Code and C/C++ extension versions. Trace how Rename Symbol handles the local Tag definition and the unrelated /usr/include/google/protobuf/parse_context.h occurrence, then verify that unrelated files are excluded or placed in Candidates for Rename rather than Confirmed Rename.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.