microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.44k stars 1.53k forks source link

Extend 'Rename Symbol' feature to support renaming macros #6194

Open programminghoch10 opened 3 years ago

programminghoch10 commented 3 years ago

Type: LanguageService

Describe the bug

Project size is irrelevant, happens also in one file as seen below.

Steps to reproduce

#define TEST_CONSTANT "string"

void main() {
  std::cout << TEST_CONSTANT;
}
  1. Try to rename the TEST_CONSTANT using F2 (Rename Symbol).
  2. Notice it only renames usages, but not the define itself.

Expected behavior

It should also rename the constant itself.

Colengms commented 3 years ago

This feature is currently specific to semantic symbols. For example, if you have functions named foo() in multiple classes, and select just one class's instance of foo(), it should not rename foo() in unrelated classes. I don't believe it's intended to perform the equivalent of a Replace All, which can be done using the Search pane. We can consider this a request to extend the feature to macro names, if possible. We may be able to ensure that only sources leveraging the same #define statement (and not another unrelated #define of the same name) are modified.

dzid26 commented 1 year ago

We may be able to ensure that only sources leveraging the same #define statement (and not another unrelated #define of the same name) are modified.

What do you mean unrelated defines? Defines are global and should be unique.

Right now the behavior is very surprising.

ghost commented 11 months ago

Still not fixed :/

mrx23dot commented 1 month ago

v1.73 fails to rename simple thing as main.c image

image