Skip to content

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

Closed

Description

@programminghoch10

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.

Activity

  1. Colengms commented on Sep 23, 2020

    @Colengms
    Contributor

    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.

  2. changed the title [-]Define directives don't get renamed correctly[/-] [+]Extend 'Rename Symbol' feature to support renaming macros[/+] on Sep 23, 2020
  3. dzid26 commented on Sep 17, 2022

    @dzid26

    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. EDIT: they don't have to be though.

    Right now the behavior is very surprising.

  4. mrx23dot commented on Jul 11, 2024

    @mrx23dot

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

    image

  5. costyn commented on Dec 14, 2024

    @costyn

    Sad that this bug is still not fixed :( But at least I know I'm not doing it wrong.

  6. xenkuo commented on Dec 15, 2024

    @xenkuo

    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.

    It still can't work.

    BTW, the macro in language C is NOT considered as a semantic symbol? The "Go To Definition" can support it, the Outline panel can support it as well.

    To be honest, I'm not really understand the exact definition of the "semantic symbol" here..

  7. dzid26 commented on Dec 15, 2024

    @dzid26

    It can be implemented the same as "Replace All". Just let user confirm with checkboxes which definitions they don't want to rename.

    At this point, instead of making it perfect, just make it work :)

    Unless you are bound by the language server limitations. Then let the sadness continue.

  8. Dromantor commented on Jan 16, 2025

    @Dromantor

    I really don't get how such simple things can be broken for ages, while any IDE out there handles this properly from the start. (And no, "this is not an IDE, it's an editor, you are using it wrong" is not a catch-all excuse for things remaining half-broken. Other editors with C(++) support don't fail at this either.)

  9. mrx23dot commented on Jan 16, 2025

    @mrx23dot

    I agree, basic functions should have priority over new fancy features.

  10. 7 remaining items

  11. sean-mcmanus commented on Oct 28, 2025

    @sean-mcmanus
    Contributor

    sorin0101 It was not "intentional" -- the find all references code was skipping macros for some reason, so when I change the code to stop skipping macros then rename works...I have to look into if there are any cases where there are problems with that change though. This should have been fixed 5 years ago (seems like it just fell through the cracks -- thanks for complaining it about it, otherwise we wouldn't have noticed).

  12. moved this from In progress to Pull Request in cpptoolson Oct 28, 2025
  13. added
    fixedCheck the Milestone for the release in which the fix is or will be available.
    on Oct 29, 2025
  14. moved this from Pull Request to Done in cpptoolson Oct 29, 2025
  15. sean-mcmanus commented on Nov 4, 2025

    @sean-mcmanus
    Contributor
  16. locked and limited conversation to collaborators on Jan 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

Projects

  • Status
    Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions