Comments (10)
Thanks for adding me as a contributor, I have not seen it done in this way on Github, nice :)
I am working through Refactoring: Improving the Design of Existing Code (2nd Edition), and it is amazing! The more of that that can be automated the better... I can see things getting pretty complicated for the advanced ones, but I dream of a day you can press a button and perform all the complex logic refactorings automatically... that really would be magic!
from abracadabra.
@nicoespeon Hello. I just wanted to add that this issue will hopefully become a non issue with the next update of VS Code, they are adding refactor preview! This is going to be the best update for VS Code refactoring for a long time, so I hope it will all work well with your extension :)
https://github.com/microsoft/vscode/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+Refactor+preview
from abracadabra.
Thanks for this very nice bug report @David-Else π
I'll investigate what's going on π§
from abracadabra.
@all-contributors please add @David-Else for bug
from abracadabra.
I've put up a pull request to add @David-Else! π
from abracadabra.
You're welcome, I like how all-contributors acknowledge for all kind of contributions. Raising up relevant bugs helps a lot!
And yes, Refactoring 2nd Edition has a strong influence on the development of this extension. My former experience with IntelliJ refactorings too. As you said, advanced refactorings are not easy, but when there is a recipe it can be automated and save us so much time π
from abracadabra.
I gave this one more thoughts.
TL;DR:
- that's indeed a problem
- it's hard to solve and I don't think it's a frequent one
- so I won't fix it and I'm closing the issue
- but I'm open to further feedbacks, ideas or PRs to help me solve that
Detailed explanations
When we do the refactoring, we insert the code, then we mutate the selection to put the cursor at the correct position:Β
abracadabra/src/editor/adapters/vscode-editor.ts
Lines 43 to 46 in 8eb5340
When we "undo" (Ctrl+Z), then "redo" (Ctrl + β§ + Z) the refactoring, it doesn't redo that mutation. So the code is inserted again, but the cursor ends up at the end of the newly inserted code. Because most refactorings would rewrite the whole code (preserving what wasn't modified), the cursor is likely to end up at the end of the file.
I don't know how to make the "redo" understands the selection mutationβif that's even possible.
The only way I see to kinda-fix this would be to fine tune each refactoring so they only insert code that changed instead of the whole code. But that's much more complex to do it (properly). And even with this, I think the cursor would still end up further than we would expect.
That's why, considering this happens when you "undo", then "redo" a refactoring and knowing the complexity of the fix, I will not fix it unless:
- Many people report that this is a problem for them because they undo-redo refactorings
- Someone come up with a simpler idea to fix this (or a PR)
from abracadabra.
Thanks for the detailed info!
from abracadabra.
You're welcome. That's only fair to explain why I'm closing this. I don't have a good solution in mind yet and I don't want this to stay open for 2 years without any feedback.
Sorry I couldn't help more for this. I hope I (or someone) will find a simple way to fix that π€·ββ
from abracadabra.
@David-Else that sounds great indeed π
I can see they're working on improving the way refactorings are provided to the users. That's nice. That will probably mean less custom implementation here for more native solutions (e.g. a keybinding to see the list of available refactorings under the cursor position).
from abracadabra.
Related Issues (20)
- Automatically "Convert to Template String" if we write ${} in a string HOT 2
- Abracadabra does not play nice with cursorless HOT 29
- Inlining JSX removes curly braces HOT 1
- Extract refactoring runs on JSX attribute HOT 3
- Inline async arrow function misses braces HOT 1
- Abracadabra replaces system key binding HOT 3
- Extract Variable insert position doesn't right HOT 2
- change activationEvent to onLanguage
- Idea: Migrate to TypeScript plugin HOT 4
- "Change Signature" doesn't work on a nested function HOT 3
- "Add explicit type" refactoring HOT 1
- Inline variable if ternary misses parens HOT 5
- split declaration & init when working inside class
- JS and TS code without `;` is broken after refactoring HOT 3
- Abracadabra extension causes performance issues with other extensions (prettier formatting, etc.) HOT 7
- More inline variable missing parentheses edge-cases HOT 1
- Can't move class to an existing file HOT 2
- Move to new file: configure case of the new filename HOT 3
- Upgrade babel/traverse ti eliminate vulnerability. HOT 1
- Convert to Arrow Function: Does not work with a `export default function` HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from abracadabra.