p42ai / js-assistant

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

Cursor jumps after refactoring #33

Closed hediet closed 2 years ago

hediet commented 2 years ago

Consider diffing for more precise edits.

recording

lgrammel commented 2 years ago

Thanks for the bug report! I'll take a look - it seems the text the cursor was originally at got removed in this case. Do you know how VSCode updates the position on edits? In a lot of cases it seems to just work (as in, the cursor remains at the same position).

hediet commented 2 years ago

In a lot of cases it seems to just work (as in, the cursor remains at the same position).

It works when the edit does not touch the cursor. Otherwise, the cursor will be placed at the boundaries.

I doubt this will be useful for you though.

I recommend you to explicitly set the cursor after sending the edit.

lgrammel commented 2 years ago

Thanks! Moving the cursor seems like a good approach, agreed.

lgrammel commented 2 years ago

I have trouble reproducing this bug with P42 v1.121.2 and VS Code v1.68.1. Which VS Code version are you using?

https://user-images.githubusercontent.com/205036/177507251-7271f343-7d9b-4f06-a720-9e5df2d139c9.mov

One of the things that could be causing this is that P42 sometimes produces larger-than-needed edits. I'll add a edit minimizer soon, this should potentially deal with some of this, but until I can reproduce it I can't say for certain.

Another reason could be that there is some text edited that is off-screen in your recording. Could you share the original snippet in case you still have it?

lgrammel commented 2 years ago

I've tried this again with VS Code 1.69 and P42 v1.124.0 (which minimizes edits). I can't reproduce the bug for this combination. Please re-open if you still run into it.