adoy/vim-php-refactoring-toolbox

Rename local variable

gambledor opened this issue · 18 comments

MacVim 7.4
When I rename a local variable appears the dialog I write the new name inside it but the name is not changed.

adoy commented

Hi could you give me an example of file where it doesn't work ? Also do you know the magic mode ?

The file is your playground.php
I'm sorry but I do not know the magic mode; let me know how to enable it and I wll be glad to help you.

adoy commented

Just by curiosity, did you try other refactoring ? Which variable did you try to rename ? Was it $renameMe ? I'll try to get my hands on a MacVim 7.4 to try it.

Yes I did, the only one that doesn't work is this one.
I tried both variables $renameMe and $renameMeAlso

adoy commented

Could you please try this command in your vim in the original playground file ?

:exec '16,21:s/$renameMe>/$foobar/ge'

That command as is applies no change.
I reckon the problem could be in '>'; without it the substitution works even if not properly.

adoy commented

Sorry I missed a char in my command. Could you run this one ?

:exec '16,21:s/$renameMe\>/$foobar/ge'

I tried this refactoring on Vim Mac 7.4 on a friends mac and I had no issue with it.

Right, now it works

adoy commented

Ok this is strange. This should be the exact same command executed in the refactoring.

Could you add this line on line 308 (after or before the exec) and run the refactoring again ? You should see the output on the bottom left.

echom l:startLine . ',' . l:stopLine . ':s/' . a:search . '/'. a:replace .'/ge'

I put it before the exec
I restarted vim
I did the refactor and nothing shows up but ':call PhpRenameLocalVariable()'

adoy commented

Could you use the version from the branch 1-Rename-local-variable
Or the file here : https://raw.githubusercontent.com/adoy/vim-php-refactoring-toolbox/1-Rename-local-variable/plugins/php-refactoring-toolbox.vim

And tell me if it's not working the output you get ?

Thanks a lot for your help

adoy commented

Did you have the chance to try ?

Hi, this is the output
16,21:s/$$renameMeAlso>/$testit/ge
we've got a '$' sign more

adoy commented

Ok I see the problem. I'll have to look at how it's possible that expand('<cword>') on my vim return the variable without $ and your don't. I'll get back to you ASAP :-) Thanks

adoy commented

Could you run this and tell me the output when you're in the playground.php file ?
:set iskeyword?

I suspect there is something in the keyword that differ in our instances

Do you mean this?
iskeyword=@,48-57,_,192-255,$

adoy commented

Ok thanks I know the problem now. You have $ in your keyword. I created a patch to make sure that $ is not included which should make both our config work.

Could you test the version here :

https://raw.githubusercontent.com/adoy/vim-php-refactoring-toolbox/1-Rename-local-variable/plugins/php-refactoring-toolbox.vim

Ok, I state the last patch works for me too 👍