vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

Extend 'Rename Symbol' feature to support renaming macros

Open programminghoch10 opened this issue 5 years ago • 2 comments

Type: LanguageService

Describe the bug

  • OS and Version: Windows 10
  • VS Code Version: 1.49.1
  • C/C++ Extension Version: v1.01
  • Other extensions you installed (and if the issue persists after disabling them): PlatformIO, Does persist.
  • Does this issue involve using SSH remote to run the extension on a remote machine?: No

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.

programminghoch10 avatar Sep 23 '20 09:09 programminghoch10

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.

Colengms avatar Sep 23 '20 23:09 Colengms

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.

dzid26 avatar Sep 17 '22 19:09 dzid26

Still not fixed :/

esnosy avatar Sep 24 '23 02:09 esnosy

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

image

mrx23dot avatar Jul 11 '24 12:07 mrx23dot