phpactor icon indicating copy to clipboard operation
phpactor copied to clipboard

[RPC][extract_expression] Extract expression without selection potentially breaks the code

Open tkotosz opened this issue 4 years ago • 1 comments

Currently if extract_expression executed while nothing is selected (offset start = offset end) then it potentially breaks the code. (well surprisingly sometimes it figures out what to do anyway - wow)

I think in this case it would be safer if the command would no do anything.

What do you think?

tkotosz avatar May 04 '20 07:05 tkotosz

It's basically quite immature - it needs more tests! https://github.com/phpactor/code-transform/blob/master/lib/Adapter/TolerantParser/Refactor/TolerantExtractExpression.php

dantleech avatar May 17 '20 20:05 dantleech

This issue should be fixed. At least there is a test for it.

https://github.com/phpactor/phpactor/blob/137b6a0fbd0e46bf729c1e439a068627e2a614c1/lib/CodeTransform/Tests/Adapter/TolerantParser/Refactor/TolerantExtractExpressionTest.php#L140

mamazu avatar Jan 22 '23 01:01 mamazu

thanks @mamazu

dantleech avatar Jan 22 '23 10:01 dantleech