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

Implement prepareRename so rename isn't invoked on comments/strings/etc.

Open mehlian opened this issue 1 year ago • 3 comments

Environment

  • OS and Version: Windows 10 x64
  • VS Code Version: 1.84.2
  • C/C++ Extension Version: 1.21.6
  • If using SSH remote, specify OS of remote machine: none

Bug Summary and Steps to Reproduce

Bug Summary: When you try to fix typo in variable name or in comment using 'Code Spell Checker' extension then 'A definition for the selected symbol could not be loaded.' error popup shows up.

Steps to reproduce:

  1. Install 'Code Spell Checker' extension version 3.0.1
  2. Install 'C/C++' extension version 1.21.6
  3. open any .cpp or .h file
  4. create any comment with spelling mistake
  5. try to fix spelling mistake using bulb icon or ctrl+. shortcut
  6. pick correct word from popup
  7. error popup appears but spelling mistake is fixed
  8. repeat steps for any variable with spelling mistake

Expected behavior: No error popup should appear.

Configuration and Logs

none

Other Extensions

'Code Spell Checker' version 3.0.1

Additional context

No response

mehlian avatar Aug 23 '24 12:08 mehlian

I would say this is at least partially bug with the Code Spell Checker extension, because it seems like it's triggering a rename, which causes our extension's rename provider to be invoked. Do you get this error on a valid C++ variable?

However, it seems like this could also be partly our bug, because in TypeScript it shows a different error message saying that a comment or string cannot be renamed, while our extension pops up the rename dialog and then shows the "A definition for the selected symbol could not be located.".

sean-mcmanus avatar Aug 23 '24 21:08 sean-mcmanus

I just looked into our implementation -- we need to implement the vscode.RenameProvider.prepareRename at https://github.com/microsoft/vscode-cpptools/blob/main/Extension/src/LanguageServer/Providers/renameProvider.ts#L20 .

sean-mcmanus avatar Aug 23 '24 21:08 sean-mcmanus

I would say this is at least partially bug with the Code Spell Checker extension, because it seems like it's triggering a rename, which causes our extension's rename provider to be invoked.

This is a feature of 'Code Spell Checker' extension. It fixes spelling mistakes for variables, functions etc. by invoking 'Rename Symbol' function to fix all instances of this symbol in source code.

mehlian avatar Aug 24 '24 08:08 mehlian

This feature request is being closed due to insufficient upvotes. Please leave a 👍-upvote or 👎-downvote reaction on the issue to help us prioritize it. When enough upvotes are received, this issue will be eligible for our backlog.

github-actions[bot] avatar Mar 01 '25 12:03 github-actions[bot]