This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: Code Composer Studio
Half of the time when I copy something and paste over an variable which is defined somewhere else, CCS jumps to that reference where it is defined and it paste over that. It's as if me pasting it, tells the editor to find where the text I am replacing is defined and go replace it there. It basically jumps to that file and replaces it.
But it only does it some times
Like I have code as follow: (this is just a hypothetical piece of code for simplicity)
1) int myVariable;
2) int yourIVariable;
3) int myString;
4) myString=1;
Then I copy "your" and paste it over myString at 4), then it replaces myString at 3) to "your"
1) int myVariable;
2) int yourIVariable;
3) int your;
4) myString=1;
what I expected to happen is that myString at 4) should be replaced like follow:
1) int myVariable;
2) int yourIVariable;
3) int myString;
4) your=1;
if myString is defined in another file, even my global variables file, it will jump to that file and go paste it over that variable definition.
I find this issue annoying and dangerous, as it can mess things up unintentionally, so I need to find a way to disable that what is causing this.
Marius,
It seems like the "refactor" feature "rename" is kicking in.
There is a refactoring feature that allows you to say that you want to rename a variable/function... and it will then rename the relevant instances.
Right click on a variable and select refactor->rename
It then prompts you to specify the new name
After you type the name you can see that all instances get replaced.
I am attempting to reproduce what you are seeing and will see if I can find a way to turn that feature off.
Regards,
John
If you look under Window -> Preferences and under C/C++ there is a "Rename in editor without dialog" option which seems to ticked by default in CCS 8.0.0.00016:Marius Dumas said:I do not get any prompt message, it just do it automatically, although it does seem to have a highlight on all occurrences of the variable as in your screen shots, but no prompt to rename or refactor.
[You will need to select "Show Advanced Settings" on the preferences dialogue before the above options are visible.]
Not sure if having the "Rename in editor without dalog" selected is causing your automatic change, but found the option mentioned in Eclipse: “Refactor - Rename” completely messed up, replacing arbitrary characters in file
I haven't been able to reproduce the behaviour in CCSv8.0 or CCSv8.2. The option that Chester has mentioned makes sense. I leave the option on and I can see it highlight the other occurrences of the variable but when I type the new name or paste it does not replace the other instances.
I even tried the exact lines and sequence you used and it still works as expected for me.
Let us know if disabling the option that Chester mentioned makes a difference.
Regards,
John
Thank you
I have changed the "rename in editor without dialog" and turned it off, but still.
For example it just happened again
I had code:
LCDsymbolDisplayOn(SMB_K20);
LCDsymbolDisplayOff(SMB_K21);
So I wanted to change the On to Off. I select and copy "Off" and select the part "On" part and paste, it jumped to where the function is created
int LCDsymbolDisplayOn (unsigned char character,int lcdm){
and changed it automatically to
int Off(unsigned char character,int lcdm){
What I have noticed with repeating experiments it happens on the Copy and Paste and also on Paste alone. But you select the part you want to replace and paste over it, then it goes to the function or reference it was before the pasting.