p42ai / js-assistant

120+ refactorings and code-assists for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=p42ai.refactor
MIT License
119 stars 7 forks source link

inline refactor bug in jsx #15

Closed skt-t1-byungi closed 2 years ago

skt-t1-byungi commented 2 years ago
export function App() {
  const handleClick = () => console.log(test);
  return (
    <>
      <div onClick={handleClick}>test</div>
    </>
  );
}

If the handleClick function is refactored inline, the output is as follows. (<,t is repeated twice )

export function App() {
  return (
    <>
      <<div onClick={() => console.log(test)}>ttest</div>
    </>
  );
}
lgrammel commented 2 years ago

Thanks for the bug report!

I've tried the example that you have provided and inlining handleClick works for me:

https://user-images.githubusercontent.com/205036/156144750-bcd79465-0bb1-4dfa-ab82-bce60e9aca23.mov

Which P42 version are you using? Were there any syntax errors in the file that you were refactoring?

skt-t1-byungi commented 2 years ago

d2 The version is 1.86.1. I tested with the same code. I am on windows os and I use many other extensions as well. (I'm busy, I'll test later by deleting other extensions. 😅)

lgrammel commented 2 years ago

Thanks, I was able to reproduce it. It is caused by the \r\n end of line sequence under windows. I will prepare a fix.

lgrammel commented 2 years ago

@skt-t1-byungi I have just released version 1.86.2, which fixes the bug. Please re-open this issue if you still encounter the bug in 1.86.2 or higher. Thanks again for the bug report!