-
-
Notifications
You must be signed in to change notification settings - Fork 372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: rename by keeping existing text #790
Comments
I agree this would be nicer. However rename is pretty broken anyway :/ First need to fix the jedi stuff. It's also not that easy to implement this kind of stuff with VIM. |
I think this is supported by now, please re-open otherwise. |
Nope, I don't see it. Can't re-open an issue closed by a collaborator. Please re-open.
|
Interesting - thought you could always re-open your own ones. Ok, thought like improvements to usages would have addressed that, but it replaces the whole word. I've remembered that there is a visual mode I've added a while ago, but it also works not as expected, and appears to be broken even currently. How would you expect this to work then? I've looked into it a bit already, and think this could be improved. What might not be possible though is having both operator-pending mode (i.e. I think we could have |
How about this: Currently if I mark the word for renaming using visual mode (vw) and then < leader >r I get at the bottom command line: (This does not work for me if I enter a new name and hit enter btw. jedi-vim: No usages found here. │ Maybe that's what you were referring to...) But if we assume that can be fixed... I think that would be an easy and elegant solution. I would keep the key < leader >r. |
I worked on this a bit, and I think it could work just by jedi-vim getting all the usages at the current cursor position when it starts (visual, normal, or operator mode), then let the user rename it (without the extra input that is currently being done with visual mode), and then replace all usages (gathered in the first step) with the new name. |
@blueyed There's currently no easier way than this, but if this is really a requirement and would help us, I'd be willing to implement it. It has been planned for a long time to give Jedi users a context helper (for questions like this). In general I agree with your approach that we just don't delete the current name and let the user rename it. This could work very well. However I'm not sure about all the edge cases. It might be hard to deal with user skipping in and out of normal mode. Maybe do it in a way that if a user hits the command a second time that it starts renaming? I don't know. Generally I would introduce a |
@davidhalter It worked quite well already, until I got side-tracked by all the improvements to the tests etc.. ;) I think there is no edge case regarding skipping in and out of normal mode: we prepare the rename when it gets triggered, then go into insert mode (the visual mapping returns "c", while the normal mode mapping would trigger "ciw"). It might be better to only store the current script when preparing for the rename (going into insert mode), but not get usages already for the case where it gets aborted, and to not block the initial editing. This then would be used to get the original usages. |
Current implementation deletes the entire name to be renamed and user has to enter the entire new name.
Often, especially with long name, we want to have a small modification like fixing a typo or adding a letter/word.
PyCharm has a nice implementation that keeps the previous text, allowing to edit/overwrite it and then re-factor the code.
The text was updated successfully, but these errors were encountered: