It would be very useful if this tool also supported renaming of variables.
I agree.
@tinganho, Renaming is a feature that we consider part of a much larger work-item to implement more intelligent auto-complete (aka Intellisense(tm) in the Visual Studio world) for our extension. We hope to roll that out in the coming months.
I agree too. Is there some roadmap or state of the rename symbol feature? The greazer's comment is old and doesn't make sense now, when intelligent auto-complete aka Intellisense is already in VS Code using C/C++ extension. Just the rename symbol is missing :( How is it going?
Actually, the IntelliSenseEngine features we have so far are just error squiggles and hover (quick info). We are currently working on getting auto-complete added (it's currently using the old implementation that has issues, such as no local variables and too many invalid results). Unfortunately, we don't have a roadmap for when rename will be implemented.
Now that reference highlighting is implemented in the September cpptools update, it seems quite awkward that Change All Occurrences changes a different set of occurrences to what are highlighted. Is the rename feature the intended way to do that in other languages? It almost feels like a bug in VSCode now that this inconsistency is created.
Hmm... I never thought about that. Reference highlighting only ever applies to a single file at a time but rename works across the entire project so I never made that connection. Unfortunately, "rename" is correlated to "find all references" - which we have not implemented yet - so the addition of reference highlighting doesn't get us much closer to the implementation of rename.
Hi guys - the extension works great! - just wondering if there are any updates on this issue?
@dprandle There are no updates on renaming. When we decide to start working on renaming it will be added to a milestone. It looks like our 5th top up-voted issue: https://github.com/Microsoft/vscode-cpptools/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc .
@sean-mcmanus @dprandle I want to add, that from my point of view, it's highly coupled with 1st top up-voted issue (if you can find all references, then you just rename them all). I know, it's a bit different, but solving that moves it forward a lot I think.
@salda Yeah, most of the top features are dependent on the multiple translation unit IntelliSense component, which hasn't been ported from VS 2017 yet. We want to fix the major problems with configuration for single translation unit IntelliSense before starting work on that, e.g. recursive includePath, compilerPath for WSL/cl.exe (better guessing/defaults), global settings, etc.
When you do bring over intellisense please base it on libclang. In the current intellisense (in VisualStudio 2017) I have code that compiles correctly (I am using the clang tools extension with clang 6.0: https://marketplace.visualstudio.com/items?itemName=LLVMExtensions.llvm-toolchain) but according to intellisense the source has errors, because (I presume) it uses a faulty msvc front end (it is conformant c++17 code that will not compile with the current trunk of msvc). It is annoying to have red squiggles through source that actually compiles without error or warnings.
I think it's better to just say not to use VS2017's compiler.
I have the same problem from the start of VSCode project.
I would prefer GCC.
I'm not using msvc, I am using clang, however, intellisense still uses the msvc front end apparently, which leads to a disconnect between what is actually compilable and what intellisense thinks is compilable. If intellisense is based on libclang (for vscode) then everything will be good, if it is based on msvc then it will be bad. I can live with the issue in Visual Studio, but I would like to not have the same issue in vscode when it gets full intellisense (i.e. intellisense == good, intellisense based on msvc == not so good).
@rtosman, our IntelliSense engine has clang and gcc compatibility modes. If you are seeing incorrect error squiggles with those modes, please open a new issue and we'll investigate getting them fixed. This issue is about support for renaming.
@bobbrow , I was referring to what visual studio does, in the context of this discussion with reference to the comment from @sean-mcmanus "Yeah, most of the top features are dependent on the multiple translation unit IntelliSense component, which hasn't been ported from VS 2017 yet."
I have compatibility mode in vscode set to "clang-x64" and it works fine within the limitations discussed. My point was that the intellisense that visual studio has does not correctly operate with clang, which I presume is because the intellisense engine in visual studio is based on msvc (I presume this to be the case, since the errors it "squiggles" are the same errors I would get if I did compile the code with msvc. The errors in question are clearly out-of-scope for the current level of intellisense support in vscode and I do not see squiggles with the same code in vscode.
I was simply asking that when you do bring over full blown intellisense to vscode (part of getting renaming working) to please base it on libclang so that it doesn't suffer from the problems that visual studio intellisense currently does when using clang as the toolchain.
I would like to base it on GCC.
@sumonero sure, that works as well. The specific code in question compiles fine with gcc as well, so I have no hard data to prefer clang over gcc in that respect.
We actually do not use MSVC for IntelliSense (nor does Visual Studio). We use a different front-end which supports msvc, gcc, and clang modes. If you can open an new issue and show us which cases are providing incorrect squiggles for you, we can work to improve our existing implementation.
The errors in question are clearly out-of-scope for the current level of intellisense support in vscode and I do not see squiggles with the same code in vscode.
I'm not following you. Our goal is to provide an accurate linting experience, so if there are false errors reported, we'd like to know about them so we can fix our implementation. And is there a typo here? I thought the complaint was that there were incorrect squiggles in vscode.
Using libclang as an additional engine is not out of the question, but it is also not a trivial change and not on the schedule at this point. I can pretty much promise you that when we do finish porting all the features they will not be implemented with libclang as the front-end.
@bobbrow my apologies, I didn't think this was a forum where it would be appropriate to report issues with Visual Studio (and they really don't bother me that much as I use vscode predominantly).
No, I have not had issues with vscode (I wasn't surprised as I didn't believe that it was doing sufficient analysis to detect the type of error that is being reported by intellisense on Visual Studio).
In any case, I have the code that fails to compile with msvc here (reduced test case): https://godbolt.org/z/j5mJJ0
On intellisense (under Visual Studio not under vscode) the intellisense error is the same as the compiler error (which is what lead me to believed the front end is the same). As you can see the code compiles fine with gcc (trunk and 8.2) as well as clang (trunk and 6.0). I tested with msvc pre 2018 and msvc 2017
I was holding out libclang merely as a possible solution, anything that produces the same results is fine.
@rtosman You're supposed to be able to get IntelliSense to work with clang in VS via setting the CppProperties.json correctly -- see https://docs.microsoft.com/en-us/cpp/ide/non-msbuild-projects?view=vs-2017#configure-intellisense-with-cpppropertiesjson . If you have problems getting that to work, I would recommend using the "Report a Problem..." feature in VS (I created an issue at https://developercommunity.visualstudio.com/content/problem/327884/c-compiler-fails-to-compile-lambda-that-captures-a.html ). The IntelliSense errors attempts to mimic the compiler used, so if it's set to msvc mode, it's more likely to give the errors that msvc (cl.exe) gives.
@sean-mcmanus Correct me if I am wrong, but I believe the CppProperties.json file only works for "Open Folder" projects. Can CppProperties.json be used with solution file based projects as well?
I am using a solution and I have set the toolchain to "llvm" in the project properties so I expect that setting to be passed on to intellisense.
@rtosman Yeah, you're right, it's for Open Folder, not projects. If you're using the a project, the "mode" is supposed to be picked up by IntelliSense from the project.
@sean-mcmanus thanks for confirming. We are off track now though, as I really wasn't look for a fix to Visual Studio, as I use VS Code mostly :-)
FWIW. I did try setting the intellisense mode in c_cpp_properties.json under vscode to "msvc-x64", and I didn't get the errors that I get with Intellisense under Visual Studio 2017.
@sean-mcmanus @bobbrow Actually, after looking carefully at my vscode intellisense configuration, I realized I had a misconfiguration. I fixed the misconfiguration, and now I do get the erroneous error report from intellisense on vscode (the same as I get with intellisense on Visual Studio).
Here is my c_cpp_properties.json file:
{
"configurations": [
{
"name": "Windows",
"includePath": [
"${workspaceFolder}/**",
"c:/SFML-2.5.0/include"
],
"defines": [],
"compilerPath": "c:/Program Files/bin/clang++",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
So, it appears that intellisense is using the msvc front end and it ignores the "intelliSenseMode" setting (at least wrt to this specific behavior).
@rtosman As mentioned previously, the msvc front-end is implemented in cl.exe (c1xx.dll), and we don't use any of that code. Clang on Windows uses Microsoft extensions (msvc-x64 mode, not clang-x64) in order to compile the Windows headers and it is a different mode than the non-Windows clang (i.e. via /usr/bin/clang with WSL). What bug are you experiencing exactly? Can you file a new issue with the repro steps?
@sean-mcmanus Did you look at my compiler explorer link from my comment above. That details the error very concisely. The error log from my actual code base (the compiler explorer link is a reduced example) within vscode is:
Yes, now that I know it exists in vscode I will file a report.
Symbol based refactoring is highly desired for my workflow. The multi select ctrl+F2 renaming is insufficient as it applies the rename, often incorrectly, across the whole file. This would bring C++ up to speed with other VS code languages that support all the refactoring features listed here: https://code.visualstudio.com/docs/editor/refactoring
This issue was opened in 2016, and it is still not implemented. The devs of this tool very clearly do not develop any code in C/C++, as they fail to realize that this feature is absolutely crucial for that.
Until you've decided to implement this feature, I'm sadly forced to leave this editor for one that supports it. Hopefully not for too long.
I'm sorry for your frustration and we're sad to see you go, but resorting to insults will not increase the priority of this request. This is a free extension with a very small team of developers working on it so we have no choice but to prioritize feature requests based on the number of upvotes. This request is on our radar but is not currently the most upvoted feature. As of this writing it's number 4.
But maybe it's not upvoted, because only few people develop C/C++ in VSCode, because without this feature it's almost impossble to. For example in our company, 3 other less senior developers asked me what IDE I prefer for C/C++ and I told them that VSCode, but that I can't recommend it to them, because of this feature missing. And it was the same story in my previous companies. So I guess the demand is huge. Btw I checked the n1 upvoted feature and it's closely coupled with this one. It's so coupled it's almost interchangeble.
We have telemetry on the number of people writing C++ in VS Code and it is actually not a small number.
And yes, you are correct. The number 1 feature is very closely related to this one (it's basically a dependency).
@Nearoo We implement our extension processes in C++. I normally use VS Code but I switch to Visual Studio when I need some advanced feature like renaming, memory breakpoints, etc. VS Code's find/replace ability can also be used to assist with renaming.
We've done some preliminary work on the number 1 upvoted issue (Find All References) in regards to improving Go to Definition -- we're still working on getting IntelliSense-based definitions/references to work across translation units, which is a pre-requisite for renaming (https://github.com/Microsoft/vscode-cpptools/issues/2536). The code that gets the correct symbols is shared between all the features mentioned.
I would just like to add my support to bobbrow's comment. In windows there are plenty of nice IDE's, but in the linux world there are only a few and most have "issues". I have tested many IDEs for c++ (qt creator, codelite, netbeans, codeblocks, eclipse, etc...) and I have shortllisted vscode and codelite, I think vscode would be our (team of 10-15 people) tool of preference if it had refactoring, but without it its number 2 choice.
@code-fodder @salda I develop c++ using only vscode mainly because I switch so much between operating systems. Used to use emacs but prefer vscode because configuring for c++ is so much less labor intensive, and vscode is more mainstream for extensions.
Until multi-translation unit is ready, I have been using cquery extension for c++ auto-complete/refactoring and disable the language server in settings for cpptools (this was a recently added feature that came from a request in a different related thread). This allows you to still use the debugger portion of cpptools.
I will switch back to cpptools for everything once they have this developed - but this allows me to use vscode for c++ dev in the meantime.
@dprandle I did not see much documentation for cquery for c++11... do you know if it supports that?, not that it matters too much just for refactoring, but if it replaces the vscode intellisense then it needs to have decent support for new language features (hopefully). But thanks for the pointer I will try it anyway.
@code-fodder Yes it does - it supports anything that clang 6 supports as that is what it uses (at the time I built it) - it builds with its own version of clang and is straight forward to set up. It uses a compile_commands.json for configuration - so depending on your build system that could be a pain to set up. I use cmake so it works just fine. Though it uses it's own version of clang as its backend, you can use whatever compiler you want to compile the code I believe. I have used it with several versions of clang and gcc with succes - haven't tried it with msvc. I'm not sure it can convert the compiler arguements from msvc in the compile_commands or not.
Is there any timeframe for this and related features. I deeply appreciate the work of the VSCode team, but it has been two years and VSCode is still not useable _for me (as I prefer to develop)_. Indeed the lack of C/C++ refactoring is the primary reason I do not have VSCode open at this very moment. I think what many of us would appreciate would be some indication of a timeline.
@jockm Rename's implementation is based on Find All References, which we're currently working on. Find All References may get pushed back to January, so my best guess for Rename is February. But we haven't decided how to handle UI and API limitations with VS Code yet (i.e. no streaming references, no rename confirmation/config dialog, etc. compared to what VS supports).
@sean-mcmanus I won't lie, this is disappointing to hear; but at least it gives me an idea. Thank you!
@sean-mcmanus January/February does not sound so bad for me. If confirmation dialogs bother you, why not having a editable JSON file instead? Like for the keyboard mapping or the settings. Or just no dialogs, the user can see all the changes in the source control view anyway. Or open all modified files, and make the respective changes as undoable modifications without saving, which is the default for TypeScript. Then the user can undo/inspect changes without source control. Anyway, having a renaming feature for C++ would be extremely great.
@xor2k wrote:
January/February does not sound so bad for me
I suppose that depends on how long you have been waiting 😉
Other languages already support refactoring in VSCode, it seems that the common refactors could be supported in the same way, or am I missing something.
I have no insight into your development process, but this feels like perfect being the enemy of good enough
For those looking for a solution, vscode-ccls provides refactoring (Rename Symbol) for C/C++/Objective-C.
You also need to build/install the ccls server and configure the extension.
Seems to be working fine for me, VS Code 1.30 on macOS, YMMV.
Any word on when this feature is coming?
@soda3x Our Find All References and Renaming work got delayed. Might be June, not sure yet.
@sean-mcmanus That can only describe that as deeply disappointing. Doubly so for an issue that has been open for 28 months now...
I have no insight into your development process, but this feels like perfect being the enemy of good enough
Probably they want to handle MACROs too :D
Shame
@soda3x Our Find All References and Renaming work got delayed. Might be June, not sure yet.
Here is my question: Why did we have to ask to find out it was delayed? There are a lot of us waiting on this.
@jockm You didn't have to ask. You could also check the Milestones at https://github.com/Microsoft/vscode-cpptools/milestones . This is issue is currently On Deck, which means we have not started work on it and don't know when exactly that work will start yet, but it's on our list of major features to implement in the next year.
We're sorry for your frustration. We're trying to be as transparent as possible. We realize that this is an important feature for many people and are trying to prioritize it against other fundamental problems with the extension that block its adoption.
@bobbrow @sean-mcmanus I wish you both all the luck in the world, but it has been years after other languages have gotten refactoring support in VSCode, and hearing that it has been delayed because of "fundamental problems"... worries me.
Again, I wish you nothing but the best.
@jockm You didn't have to ask. You could also check the Milestones at ...
Well that wouldn't have given me any expected ETA, since it literally says "No Due Date" ;)
@jockm By "fundamental problems" we mean problems with our existing features:
... We realize that this is an important feature for many people ...
It is not "an important feature". It is the showstopper feature
Hello, Is it done yet?
@fujael No. When it's done it will be marked "fixed" and assigned a milestone.
@sean-mcmanus I am guessing this is a fairly significant refactor? Just wanted to let you know, it will be worth the work :-)
@rtosman I think they know that. I know I have been fairly critical on this issue, but they are doing great work. I just personally think the priorities are wrong, and that maybe they could communicate a little better on such a highly desired feature.
Vscode, in my humble opinion is probably the best idea (at least free one)
on the Linux platform I have spent about 2-3 months trialing everything I
can find - like: qtcreator, code-lite, code locks, clion, eclipse (puke),
netbeans (really puke) and more...
From the point of view of using the idea as a makefile c++ project only
qtcreator and code lite come close. Qtcreator is near perfect except they
forcefully inhibit you from sharing configs which is unforgivable. Code
lite is pretty clunky. But both provide refactoring.
So I congratulate vscode ... But this is the biggest missing feature by a
looooong way. It should be top priority (as far as c++ goes) please make
it so soon : )
On Thu, 28 Mar 2019, 19:04 Jock Murphy, notifications@github.com wrote:
@rtosman https://github.com/rtosman I think they know that. I know I
have been fairly critical on this issue, but they are doing great work. I
just personally think the priorities are wrong, and that maybe they could
communicate a little better on such a highly desired feature.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/Microsoft/vscode-cpptools/issues/296#issuecomment-477730624,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFO85c8hgIQ949dWufrgxPSxy-ypqyn0ks5vbRIrgaJpZM4KaBV5
.
Sorry stupid phone spell corrector. Idea = IDE and code locks =
codeblocks
On Thu, 28 Mar 2019, 19:18 Alastair Dadachanji, adadachanji@gmail.com
wrote:
Vscode, in my humble opinion is probably the best idea (at least free one)
on the Linux platform I have spent about 2-3 months trialing everything I
can find - like: qtcreator, code-lite, code locks, clion, eclipse (puke),
netbeans (really puke) and more...From the point of view of using the idea as a makefile c++ project only
qtcreator and code lite come close. Qtcreator is near perfect except they
forcefully inhibit you from sharing configs which is unforgivable. Code
lite is pretty clunky. But both provide refactoring.So I congratulate vscode ... But this is the biggest missing feature by a
looooong way. It should be top priority (as far as c++ goes) please make
it so soon : )On Thu, 28 Mar 2019, 19:04 Jock Murphy, notifications@github.com wrote:
@rtosman https://github.com/rtosman I think they know that. I know I
have been fairly critical on this issue, but they are doing great work. I
just personally think the priorities are wrong, and that maybe they could
communicate a little better on such a highly desired feature.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/Microsoft/vscode-cpptools/issues/296#issuecomment-477730624,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFO85c8hgIQ949dWufrgxPSxy-ypqyn0ks5vbRIrgaJpZM4KaBV5
.
Tip: Just install the vscode-clangd
extension (supports "Find all references" too) and set "C_Cpp.intelliSenseEngine": "Disabled"
, so you can keep using cpptools for debugging.
Get the clangd
binary from LLVM: https://llvm.org/builds/
You need a build system, that generates compile_commands.json
like cmake or meson, to make this work and adjust settings.json
:
"C_Cpp.intelliSenseEngine": "Disabled",
"clangd.arguments": [
"-compile-commands-dir=build"
],
"cmake.configureSettings": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
},
Vscode, in my humble opinion is probably the best idea (at least free one) on the Linux platform I have spent about 2-3 months trialing everything I can find - like: qtcreator, code-lite, code locks, clion, eclipse (puke), netbeans (really puke) and more... From the point of view of using the idea as a makefile c++ project only qtcreator and code lite come close. Qtcreator is near perfect except they forcefully inhibit you from sharing configs which is unforgivable. Code lite is pretty clunky. But both provide refactoring. So I congratulate vscode ... But this is the biggest missing feature by a looooong way. It should be top priority (as far as c++ goes) please make it so soon : )
…
On Thu, 28 Mar 2019, 19:04 Jock Murphy, @.*> wrote: @rtosman https://github.com/rtosman I think they know that. I know I have been fairly critical on this issue, but they are doing great work. I just personally think the priorities are wrong, and that maybe they could communicate a little better on such a highly desired feature. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#296 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AFO85c8hgIQ949dWufrgxPSxy-ypqyn0ks5vbRIrgaJpZM4KaBV5 .
I fully agree, this is one of the basic feature each editor should have. I miss it now as well..
One more missing this symbol rename feature.. I will give up on VSCode just because this.. Let's get back to Eclipse..
I fell in love with this IDE right away and then immediately abandoned VS Code simply because not being able to perform the most fundamental refactoring actions renders it completely useless to me.
It's been two and a half years and despite all the comments and support nothing has been done.
I'll come back in two years to complain about it again.
It looks like it is scheduled for the July update. Could try coming back in 3 months ;-)
This has been an issue for over 2 years? Really? Really? Is VsCode considered an IDE? #_#
@dragos99 That seems to be a matter of opinion. Personally I see an IDE as something that can (out of the box) create projects, edit code, compile/run the code, and debug the code. By that definition VSCode isn't an IDE. However if you don't see creating projects as a requirement, or don't mind mixing and matching plugins to do that task, then it could be seen as one.
Now I don't see the point in using a IDE that doesn't have basic refactoring and analysis tools, but not everyone sees things that way
VS Code and its plugin is most definitely an IDE. VS Code and PlatformIO is perhaps the best environment for writing Arduino (and other dev board) code. Not having refactoring is the one annoying thing.
I would trade ALL other possible updates for this one at the moment.
It would certainly make VSCode the killer-IDE on Linux.
It would certainly make VSCode the killer-IDE on Linux.
Indeed, but hopefully is VSCode not part of embrace, extend and extinguish strategy..
It would certainly make VSCode the killer-IDE on Linux.
Indeed, but hopefully is VSCode not part of embrace, extend and extinguish strategy..
danger89, I sincerely doubt it considering that Microsoft has released the source code. They seem to be making an effort to change with the times. As far as why this feature has taken so long, i'm not an expert but I assume that shoehorning a language server into a javascript/electron app is hard.
This is _by far_ the biggest missing feature for C/C++ in VSCode compared to other languages. I'm somewhat surprised it hasn't even been started in 2.5 years. Hoping it comes out in July!
Just walking by to remind everybody that this is really important :dancing_men:
Absolutely would love to have this.
As an aside, with the current way it works can anyone suggest a more efficient way than I do now when I want to rename part of a long symbol name? This is what I do currently:
1) Select symbol name to be renamed
2) Invoke Replace in Files (ensuring case and whole word filters are selected)
3) Copy and Paste symbol name from Search box to Replace box (since I only want to change part of the symbol name)
4) Now I can edit the symbol name in the Search box
5) Hit Change All
As it stands, it would help a lot if the Replace box defaulted to the Search contents when a new Search and Replace is begun (Replace box defaults to its previous contents and that is not configurable AFAIK).
Let's hope we get full refactoring features for C/C++ this year.
I agree this is a missing feature.
However, for this to work, you need 'find all references', aka #15 first, no?
Otherwise you would be renaming the wrong things. no?
SO, in my order of importance:
since 'find all references' is also 3 years+ old, and currently scheduled for this month, I see light at the end of the tunnel.
ahh,
find all references has been moved again
Yes, we have a bit more work to do on that feature, but are planning to have it ready for Insiders in the first half of July.
I sure wish we had this rename feature in VSCode, because when I try to do it in VS 2017, it sometimes freezes and I have to End Task. I was sure that VSCode would have it. Very disappointed.
I sure wish we had this rename feature in VSCode, because when I try to do it in VS 2017, it sometimes freezes and I have to End Task. I was sure that VSCode would have it. Very disappointed.
As mentioned above, it is now in the July milestone (along with "find all references" - they are linked) - see https://github.com/microsoft/vscode-cpptools/milestone/39. So fingers crossed! And best of luck to the VSCode devs involved.
@Jimbo99 the July release is actually going to slip into August because we got a little behind on our June release, but yes, renaming is coming soon. We are working to have an insiders build with Find all References in July, with rename support shortly after.
@bobbrow Thank you for the update and clarification. I get the impression this kind of stuff goes right through the lower levels of how the editor works, so just very glad you are working on it and we can see the light at the end of the tunnel now! :) Keep up the great work.
@Jimbo99 Well yes and no. Remember that other languages already support Find All References, Rename, and other far more advanced refactors already... for years now. The only area where it might be an editor issue is that is has been said that some UI changes might be needed (though not adequately explained IMHO). None of that prevented a partial implementation. This seems to be more an issue with priorities than anything else
Please correct me if I am wrong
@jockm Yeah, the C++ case is more difficult than other languages, but we had other priorities up until the past month.
What is more important than C++ from the past 2 years xD...? Nothing is more important than C & C++ 😏😝
@XZJIsme Change All Occurrences
(or Ctrl+F2) simply replace all the occurrences of your selection. In your case all the str
literals appear in the file happen to reference to the variable str
. However they're just occurrences of literal, not references to variable. Since you didn't really _"find the definition and all references"_, you certainly cannot rename them.
@XZJIsme
Change All Occurrences
(or Ctrl+F2) simply replace all the occurrences of your selection. In your case all thestr
literals appear in the file happen to reference to the variablestr
. However they're just occurrences of literal, not references to variable. Since you didn't really _"find the definition and all references"_, you certainly cannot rename them.
@EternalPhane 我主要是疑惑,为什么vscode可以找出references和definition,却不能有重命名的功能呢?python就可以。😂
@XZJIsme
Change All Occurrences
(or Ctrl+F2) simply replace all the occurrences of your selection. In your case all thestr
literals appear in the file happen to reference to the variablestr
. However they're just occurrences of literal, not references to variable. Since you didn't really _"find the definition and all references"_, you certainly cannot rename them.@EternalPhane 我主要是疑惑,为什么vscode可以找出references和definition,却不能有重命名的功能呢?python就可以。😂
I can help explain it to you in Chinese.
上面的回答已经告诉你了,目前实现的功能是“找到所有出现的地方(occurrences)”,也就是简单的文本查找替换。并不能识别上下文语义、作用域等等。vscode只是一个文本编辑器,它只提供一个基础框架。精确找到变量定义和所有使用需要解析语言,一般通过插件实现。Python这部分已经实现了,官方的Python插件会附加安装Language Server负责解析语言。但这部分C++还没有实现。但据说快了,本来说七月份开发完。
@XZJIsme
Change All Occurrences
(or Ctrl+F2) simply replace all the occurrences of your selection. In your case all thestr
literals appear in the file happen to reference to the variablestr
. However they're just occurrences of literal, not references to variable. Since you didn't really _"find the definition and all references"_, you certainly cannot rename them.@EternalPhane 我主要是疑惑,为什么vscode可以找出references和definition,却不能有重命名的功能呢?python就可以。😂
@XZJIsme sorry for misunderstanding you. (*/ω\*)
Currently cpptools still has some corner case bugs on Go to Definition
(e.g. #3941). As @sean-mcmanus mentioned in this post, Find All References
can't work correctly until Go to Definition
is fully functional.
@EternalPhane The Go to Definition issues were fixed a few months ago. We're currently testing/fixing bugs with Find All References -- our goal is to release it in 0.25.0-insiders in a couple weeks. I'm not sure yet how much longer Rename will take (based on Find All References).
UPDATE: Still finding/fixing bugs with Find All Refs, but it's looking pretty good. Rename might take -2 weeks more?
@XZJIsme
Change All Occurrences
(or Ctrl+F2) simply replace all the occurrences of your selection. In your case all thestr
literals appear in the file happen to reference to the variablestr
. However they're just occurrences of literal, not references to variable. Since you didn't really _"find the definition and all references"_, you certainly cannot rename them.@EternalPhane 我主要是疑惑,为什么vscode可以找出references和definition,却不能有重命名的功能呢?python就可以。😂
@XZJIsme sorry for misunderstanding you. (/ω\)
Currently cpptools still has some corner case bugs onGo to Definition
(e.g. #3941). As @sean-mcmanus mentioned in this post,Find All References
can't work correctly untilGo to Definition
is fully functional.
@EternalPhane @Whotakesmyname
understood now,thank you!是我浮浅了😂
Unbelievable that such a basic feature has STILL not been implemented after 3 years, especially from a company with the resources of microsoft. Absolutely rediculous.
Unbelievable that such a basic feature has STILL not been implemented after 3 years, especially from a company with the resources of microsoft. Absolutely rediculous.
I know right? I guess being a company with a $1T market capitalization doesn't get what it used to in the old days ;-)
@L0laapk3 @rtosman I'm sorry you are feeling frustrated about the delay for this. This free extension hasn't always been funded to the degree that you would normally expect from paid products. However, we are nearing the endgame for this feature. #15 is a dependency, and we are preparing to release that soon. This will be in the following release.
@bobbrow I know for myself I am not ungrateful, but deeply deeply frustrated
It would be a bit different if other languages hadn't had refactoring for years now, or if incremental support for C++ refactors have been released over that time, or if it had been a higher priority, or even if the communication process about this been better; then I for one would have been much less frustrated
I am grateful that VSCode is a free and open product, but please don't deminimize our legitimate frustration over this either
but please don't deminimize our legitimate frustration over this either
I apologize if that was what you read out of my comment. That was not my intent. I was trying to offer hope. Unfortunately, there is only a limited amount of detail I can share publicly about why we are where we are today.
@bobbrow If you just had utilized clangd
, this could have been implemented much quicker.
please don't start this again…
We all know that MS have their own 'licensed technology' (how long back does that go ? VC 4/5/6?) and we mere mortals are not supposed to elaborate on that again and again.
@yamcenutzer maybe I am missing the references, but this was exactly what I was thinking. so don't put people that ask this into the corner. Would you be so kind and provide some references to your claim, which I indeed believe that they are right; but I would love to understand the reasoning of not utilizing clangd/LLVM API for implementing C++ IntelliSense in VS Code. :-)
Each engine has pros and cons. The Visual C++ team (whose engine we reuse) evaluates using Clang for IntelliSense from time to time, but as of the last investigation the data didn't sway us to replace our current engine based on EDG's front end compiler with a new one.
But I can envision a world where clangd
is added as an intelliSenseEngine
at some point. I can't promise any dates for that though.
so once again it was confirmed that MS will stick to EDG.
feel better now?
Let's just not distract the team from actually getting this feature released using whatever means they prefer.
In the meantime you could explore ccls https://github.com/MaskRay/ccls
We added Find All References -- see the comment at https://github.com/microsoft/vscode-cpptools/issues/15#issuecomment-519758952 for the details on how try it out. If you find bugs with that, it could also impact Rename, so let us know. Rename will take a few more weeks (?) -- in particular, overloads are currently not treated as a reference, which VS deals with via having users opt-in to add them via a special Rename UI that VS Code doesn't support yet.
How do I upvote this feature request?
@george-code You can click the thumbs up image in the initial post (that has 425+ thumbs up currently. This is the next major feature we plan to implement.
Status update: we have V1 rename, but it only renames "confirmed" references and just shows the other non-confirmed references in the Output window (similar to what Find All References does). Would people find that useful to release in an Insiders next week? Our current plan is to not release this V1 until we're able to add a Tree Container with a Preview that allows users to add non-confirmed references to the rename operation, similar to what VS C++ has, which might take a couple more weeks (not sure), e.g.
But instead of the checkboxes (which VS Code doesn't support), we're planning to put the "checked" items in a "pending rename" group at the top (similar to Staged changes with the Source Control UI), which defaults to the confirmed references, and unchecked items would go in a "rename candidates" group at the bottom, which defaults to the "other" references, with + and - buttons for moving references between the 2 groups. Showing a doc preview of the rename might go into a V3 (similar to what Search/Replace shows).
One reason this more complicated UI would be desirable is for enabling renaming of all the overloads of a method -- V1 only renames the one particular overload, although that matches what the C# extensions does. A similar issue occurs with renames of a base class method not applying to method overrides in the derived classes by default (related to https://github.com/microsoft/vscode-cpptools/issues/4078) -- in which case VS allows users to select which derived classes they want the rename to apply to.
However, the preview UI would require clicking another UI element to complete the rename -- is that okay or would people prefer a different "Rename Symbol (With Preview)" command?
Let us know if anyone has feedback on this.
It's great to see some real progress on this. I think a release that only renames "confirmed" references could be very useful, since I would guess that's what I want at least 90% of the time anyway.
@sean-mcmanus
Sorry to be a pain, but which version is this feature released in? (if it is in a release) or do I need to compile it myself (I think I would rather wait though!), thanks : )) ... been looking forward to this one for an ages - but other than this feature VS code is one of the best, if no the best, free IDE out there - thanks to you and your team : ))
@code-fodder It hasn't been released yet. We're still working on the UI (and bug fixes). We're planning for an Insider release this week, but it may be get delayed to next week.
Rename is available to try out with https://github.com/microsoft/vscode-cpptools/releases/tag/0.26.0-insiders . If you find bugs, please file new issues so we can fix them before the final release.
@sean-mcmanus VC showing progress bar running continuously while renaming a variable. Sometimes this case happens immediately, and sometimes it works fine. 🤔
When the progress bar is running continuously then I have to restart the full VC code to work it again.
Getting Error: Connection to server got closed. Server will not be restarted.
@karan-k-deepr "Connection to server got closed" means our main process has crashed. We have some known crashes we plan to fix in our pending 0.26.0-insiders3. By "progress bar" do you mean the progress bar in the document or the progress in the bottom right? If the rename side panel is open, then the progress bar in the document is expected until the rename is confirmed.
@sean-mcmanus Today I tried several times but got this error again after some trial. And progress bar at the upper side of window, Also it doesn't open any rename window this time.
I believe it is something related to the parsing of files because I can see it is printing some lines within Problems
tab when it switches files for parsing, and got stuck. Is there any way to provide logs for this?
@karan-k-deepr If you can attach a debugger to the crashing process to get a call stack or provide more repro details. 0.26.0-insiders2 has a known crash when a document is opened related to the Outline view, but we haven't been able to repro any crash involving rename yet.
I'm using 1.39.0 full info from about below and I get the dancing document status with C++ RENAME bar on the left-hand-side. There's content in there that's valid (Pending Rename items and Candidates for Rename items). The problem is, I have no idea what to click or press to get anything to apply. Eventually, if I click in the document and press a key, everything goes away, but the rename NEVER works. Was working fine up until I updated a day or two ago. :'(
I'm on Ubuntu 16.04 LTS.
Version: 1.39.0
Commit: 9df03c6d6ce97c6645c5846f6dfa2a6a7d276515
Date: 2019-10-09T06:58:03.188Z
Electron: 4.2.10
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Linux x64 4.15.0-65-generic
@monkeycoder99, if you hover over the "PENDING RENAME" title menu bar, controls for the rename list will appear, see screenshot below. Use the checkmark button to commit or apply pending rename items. Editing a file will cause rename to cancel automatically.
The rename view container will only appear if there are other references results or non-confirmed references like a string reference. If you do a rename on a symbol with results that are all confirmed references then rename will be applied automatically.
Thanks. When I hover, I can see some useful tooltips but in dark mode, these buttons are invisible.
@monkeycoder99 , I am not able to repro the issue of the buttons being invisible on dark theme with 0.26.0-insiders3. Is there a particular theme you're using that could be causing this? Can you verify if the buttons are also invisible for other dark themes?
I tried to disable all theming I could find. Besides the built in theme support in settings, I also had One Dark Pro (but disabled it). I've included a couple additional SS below. The first two are light and dark themes while hovering the mouse over a bar in the Explorer pane (built-in). The last is hovering the mouse of the Pending Rename bar for C++ Rename pane. Explorer pane buttons work/are visible. C++ Rename does not work but you can see the tooltip.
Can you check if the images for the buttons exist under the extension package path? The path to images should be under /home/<userfolder>/.vscode/extensions/ms-vscode.cpptools-0.26.0-insiders3/assets
. You should see these files https://github.com/microsoft/vscode-cpptools/tree/master/Extension/assets
If the images exists, can you try modifying the path to the referenced images in file /home/<userfolder>/.vscode/extensions/ms-vscode.cpptools-0.26.0-insiders3/package.json
to have a ./
to the beginning of the path? See example of change in this pull request.
I have no assets directory in that location. Here's what's there:
. LICENSE.txt package.nls.ko.json
.. LLVM package.nls.pl.json
bin node_modules package.nls.pt-br.json
c_cpp_properties.schema.json out package.nls.ru.json
CHANGELOG.md package.json package.nls.tr.json
cppdbg.ad7Engine.json package.nls.cs.json package.nls.zh-CN.json
cpp.hint package.nls.de.json package.nls.zh-TW.json
cpptools.json package.nls.es.json README.md
debugAdapters package.nls.fr.json ThirdPartyNotices.Mono.txt
dist package.nls.it.json ThirdPartyNotices.txt
install.lock package.nls.ja.json ui
LanguageCCPP_color_128x.png package.nls.json VCPkgHeadersDatabase.zip
We checked the shipped packages and they include the assets directory. Perhaps something went wrong when the extension was updated or installed? Can you try re-installing?
Uninstall/reinstall fixed the problem. Not sure how this happened. Maybe something with an earlier install that switched to the Preview version?
Uninstall/reinstall fixed the problem. Not sure how this happened. Maybe something with an earlier install that switched to the Preview version?
It's hard to guess how the folder was not installed. But if you get a consistent repo of a folder or files missing after installation, please create a new issue for it for us to look at.
Rename is available in 0.26.0.
I'm using with cmake tools and nothing happens except loading signal when renaming symbols. Extension info:
Name: C/C++
id: ms-vscode.cpptools
Description: C/C++ IntelliSense, debugging, and code browsing.
Version: 0.26.3-insiders2
Publisher: Microsoft
VS Marketplace link: https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools
@ryancheung Can you a file a bug with more info? What type of "loading signal" do you see? Are other features working?
I'm mean the light loading bar after doing a symbol rename. After a while, light loading bar disappears and no other action.
@ryancheung What "light loading bar" are you referring to? In the "References: Results" pane or above the document or in the bottom right notification dialog? Can you provide a screenshot? Does the output window show any "Connection closed" or "Failed to read" messages? Does it only repro for certain workspaces? Does it only repro for 0.26.3-insiders2 or 0.26.2 also?
Its above the document , no other message. I could provide gif later.
When i have other extensions disabled, renaming works...
I believe it's the cmake tools extension prevent the symbol renaming.
I have cmake compile_commands.json
enable in C++ entension configurations. Every time i open my project(it's kinda big), c++ extension is doing analysis for 16K+ files. If disables cmake tools extension, c++ extension won't do any busy jobs like the analysis.
I think c++ extension is too busy and do not do symbol renaming job until the analysis job done.
After disable compileCommands option in C++ entension configuration, symbol renaming works very well now.
After disable compileCommands option in C++ entension configuration, symbol renaming works very well now.
How did you disable it? I'm having the same issue, where I will get the light progress indicator near the top toolbar scrolling upon rename, and nothing happens...
@ryancheung What "light loading bar" are you referring to? In the "References: Results" pane or above the document or in the bottom right notification dialog? Can you provide a screenshot? Does the output window show any "Connection closed" or "Failed to read" messages? Does it only repro for certain workspaces? Does it only repro for 0.26.3-insiders2 or 0.26.2 also?
Having the same issue as described previously, Currently on 0.26.3-insiders. Looked through the logs, didnt see any weird output or disconnects, but I'm happy to collect logs and post if helpful!
seeing this
Could it be caused by a large workspace? (number of files)
@bonfire62 That's the normal progress indicator as it's confirming references. Is that getting stuck? Are you using a multi-root workspace?
After disable compileCommands option in C++ entension configuration, symbol renaming works very well now.
How did you disable it? I'm having the same issue, where I will get the light progress indicator near the top toolbar scrolling upon rename, and nothing happens...
Remove the json key from c++ extension configuration file.
@bonfire62 That's the normal progress indicator as it's confirming references. Is that getting stuck? Are you using a multi-root workspace?
@sean-mcmanus I let one instance of renaming run, and it returns after checking ~650 files and 2 usages in my first try, after around 5 minutes. I'm using the remote plugin from a windows client to a linux host
@bonfire62 What do you mean by "checking" ~650 files? Is it saying "searched" or "confirmed" in the progress UI? Searching is just lexical and should be fast and confirming is slow since it requires parsing. Both should scale to use up to your available cores, but you'll hit a performance issue if your machine doesn't have enough memory. The number of individual "uses" in files shouldn't noticeably affect performance. For tracking purposes, it would be better if you opened a new issue, although we do already have some other issues that include potential performance improvement discussions.
Most helpful comment
Rename is available in 0.26.0.