Skip to content
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

Undo of rename Java file has no effect #107740

Closed
egamma opened this issue Sep 29, 2020 · 15 comments
Closed

Undo of rename Java file has no effect #107740

egamma opened this issue Sep 29, 2020 · 15 comments
Assignees
Labels
feature-request Request for new features or functionality file-explorer Explorer widget issues on-testplan undo-redo Issues around undo/redo
Milestone

Comments

@egamma
Copy link
Member

egamma commented Sep 29, 2020

Testing #107617

  • Remote-Containers: Try a Sample
  • Select Java
  • Open AppTest.java
  • Rename the file name of AppTest.java to AppTest2.java -> the class name is also changed to AppTest2
  • undo -> the class name is changed back to AppTest but the file name is not renamed to AppTest.java
@alexdima alexdima added this to the September 2020 milestone Sep 30, 2020
@alexdima
Copy link
Member

@egamma

When you say:

Rename the file name of AppTest.java to AppTest2.java -> the class name is also changed to AppTest2

How do you rename the file name? Is there a code action that you do or do you do rename from the explorer?

AFAIK the file operations done from the explorer are not undoable (they don't push elements to the undo/redo service).

@alexdima alexdima added info-needed Issue requires more information from poster undo-redo Issues around undo/redo labels Sep 30, 2020
@egamma
Copy link
Member Author

egamma commented Oct 1, 2020

How do you rename the file name? Is there a code action that you do or do you do rename from the explorer?

The rename is done from the explorer and this triggers a refactoring.

@alexdima alexdima removed this from the September 2020 milestone Oct 1, 2020
@alexdima alexdima removed the info-needed Issue requires more information from poster label Oct 1, 2020
@alexdima alexdima removed their assignment Oct 1, 2020
@jrieken jrieken removed their assignment Oct 1, 2020
@isidorn
Copy link
Contributor

isidorn commented Oct 1, 2020

Closing as dup of #9390
This is a fair feature request which users want and that we can plan for.

@isidorn isidorn closed this as completed Oct 1, 2020
@isidorn isidorn added the *duplicate Issue identified as a duplicate of another issue(s) label Oct 1, 2020
@isidorn isidorn added feature-request Request for new features or functionality and removed *duplicate Issue identified as a duplicate of another issue(s) labels Nov 16, 2020
@isidorn isidorn added this to the November 2020 milestone Nov 16, 2020
@isidorn
Copy link
Contributor

isidorn commented Nov 16, 2020

Reopening this issue, because it is more scoped and is a good first step for investigation of undo / redo in Explorer

@isidorn isidorn reopened this Nov 16, 2020
@isidorn isidorn added the file-explorer Explorer widget issues label Nov 16, 2020
@jrieken
Copy link
Member

jrieken commented Nov 16, 2020

I know that @bpasero investigated how to use the BulkEditService in the tree - instead of the working copy service. Now sure how far he got

@isidorn
Copy link
Contributor

isidorn commented Nov 16, 2020

@jrieken thanks. I'll sync up with @bpasero

@bpasero
Copy link
Member

bpasero commented Nov 16, 2020

Yeah did not get to actually implementing this, but using bulk edit service over working copy service in explorer makes sense to me.

@alexdima
Copy link
Member

alexdima commented Nov 17, 2020

👍 It might be good to start only with the case of rename file, because, for example, AFAIK if you create a delete file workspace edit, it will end up reading the file from disk and storing it in memory in order to be able to undo the deletion. Also LMK if you run into undo/redo problems.

@isidorn
Copy link
Contributor

isidorn commented Nov 18, 2020

Thanks @alexdima for the heads up.
I started looking into this, by using the bulk edit service for all operations in the Explorer just to see how far I get and it seems to mostly work fine.
There's missing support for some operations, but I was talking to @jrieken about that

As for storing a file in memory, I guess that is not fine for large files, so could we simply have some limit on the service side?
I see a slight undo/redo issue, but I will file a seperate issue for that soon. Thanks!

We can discuss more in the standup also.

@isidorn
Copy link
Contributor

isidorn commented Nov 19, 2020

Thanks to @jrieken this now works, thus closing.
@testforstephen if you have time to try this out from the Java side.

@testforstephen
Copy link

Tried in 2020-11-19 insider version, renaming to refactor a Java file from file explorer, undo only roll back the file contents, but not restore the file name.

@isidorn
Copy link
Contributor

isidorn commented Nov 20, 2020

@testforstephen I apologize, this should hopefully work with today's insiders from 11-20.
@jrieken are there some changes needed on the Java side?

@testforstephen
Copy link

i tried the insider 11-23 again, here is the result.

  • Rename AppTest.java to AppTest1.java from file explorer. -> The class name in the file is changed to AppTest1.
  • undo -> The class name is changed back to AppTest, but the file name remains the same.
  • undo again -> The file name is changed back to AppTest.java.

It seems that @jrieken's change is for the onWill-file event, but Java extension performs rename refactoring inside the onDidRenameFiles event. We chose the onDidRenameFiles event because the onWillRenameFiles event only gives the extension 5 seconds by default to calculate the refactoring edits. If you're refactoring a large project, it may take more than 5 seconds to calculate refactoring updates. When the timeout occurs, VS Code client will force the files to be renamed to the new location, which will cause the running refactoring job to throw an exception because the underlying files have changed.

I created an issue #111208 to discuss about onWillRenameFiles limitation.

@isidorn
Copy link
Contributor

isidorn commented Nov 24, 2020

@testforstephen thanks for trying it out and for creating a new issue, let's continue the discussion there,

@isidorn
Copy link
Contributor

isidorn commented Nov 27, 2020

Adding on-testplan since there is a related test plan item and this exact case will be verified by #111208

@github-actions github-actions bot locked and limited conversation to collaborators Jan 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality file-explorer Explorer widget issues on-testplan undo-redo Issues around undo/redo
Projects
None yet
Development

No branches or pull requests

6 participants