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

Redo created file fails #111640

Closed
aeschli opened this issue Dec 1, 2020 · 16 comments
Closed

Redo created file fails #111640

aeschli opened this issue Dec 1, 2020 · 16 comments
Assignees
Labels
file-explorer Explorer widget issues under-discussion Issue is under discussion for relevance, priority, approach undo-redo Issues around undo/redo
Milestone

Comments

@aeschli
Copy link
Contributor

aeschli commented Dec 1, 2020

Testing #111015

  • Create a new file in the explorer
  • from the window menu, run Edit > Undo. File is gone ✔️
  • from the window menu, run Edit > Redo. Nothing happens
@aeschli aeschli changed the title Redo create file fails Redo created file fails Dec 1, 2020
@isidorn isidorn added the file-explorer Explorer widget issues label Dec 1, 2020
@isidorn isidorn added this to the November 2020 milestone Dec 1, 2020
@isidorn
Copy link
Contributor

isidorn commented Dec 2, 2020

@aeschli I tried reproducing this and it requires some effort

  1. Create a new file
  2. Notice how the focus is automatically moved to editor as expected
  3. Edit > Undo File is gone! The editor properly forwards the undo to the explorer (since focus is in Editor)
  4. Edit > Redo. Nothing happens. The editor does not properly forward the redo to the explorer (since focus is still in Editor)

Step 3. is expected as we discussed #111659
Step 4. is not expected as it does not align with 3. thus aslo assigning this to @alexdima

@isidorn isidorn added the undo-redo Issues around undo/redo label Dec 2, 2020
@alexdima
Copy link
Member

alexdima commented Dec 2, 2020

  1. The editor does not properly forward the redo to the explorer (since focus is still in Editor)

The editor never forwards the redo nor undo to the explorer. The editor takes the current focused file, reads the URL from that and finds an undo/redo element with that URL in the undo/redo stack.

So if you create a file called A.txt and open it and focus it in the editor. If you run undo, the undo/redo elements for file A.txt are searched and executed. So an undo results in the deletion of the file, so the file is gone.

After this, if the focus is moved to a file B.txt that you had opened (in a background tab or something), the focus is in the file B.txt. So running redo will run redo any elements related to file B.txt.

I am not sure what to do here, this works exactly as implemented. @isidorn Please let me know what you would like to be done differently by the undo/redo service. So IMHO step 4 is 100% as designed. If at step 4 the focus goes to B.txt, the redo will redo in B.txt, not in A.txt.

By the way, I agree this is bad, but at this point I suggest we don't offer an undo of file creation. cc @jrieken for opinions.

@jrieken
Copy link
Member

jrieken commented Dec 2, 2020

The editor never forwards the redo nor undo to the explorer.

Well, maybe that's what it should do? Like, when a UndoRedoSource is "empty" it could delegate to the "next" source.

@isidorn
Copy link
Contributor

isidorn commented Dec 2, 2020

@alexdima thanks for clarifying.
I agree this is expected behavior.

I see how the undo can only be done from the explorer which does not have focus in this case.
I would not change anything here atm, even though @jrieken suggestions makes sense.

After we get more user feedback we might change if the explorer undo requires focus in the explorer...

@isidorn isidorn modified the milestones: November 2020, On Deck Dec 2, 2020
@isidorn isidorn added the under-discussion Issue is under discussion for relevance, priority, approach label Dec 2, 2020
@alexdima
Copy link
Member

alexdima commented Dec 2, 2020

Well, maybe that's what it should do? Like, when a UndoRedoSource is "empty" it could delegate to the "next" source.

Yes, but the issue will remain and this might have unexpected consequences e.g. undoing in not visible files. e.g.

  • create file A.txt
  • open file B.txt, type in it
  • open file C.txt, type in it
  • open file A.txt
  • press undo: file A.txt will be deleted, focus moves to C.txt
  • press undo: typing in C.txt gets undo, focus remains in C.txt
  • press undo: (new proposed logic kicks in and will undo an undo-redo element that is not associated with C.txt): typing in B.txt gets undone which is completely invisible because B.txt is behind C.txt

I think it is dangerous to undo undo-redo elements not associated with the current focused editor because edits occur which are invisible to the user.


I also agree that it is surprising that you create a file, type in it, hold cmd+z and the file disappears. I would expect that cmd+z stops when the file is empty. It feels to me that perhaps operations originating from the explorer should not be undoable from the editor... But that would ruin the java rename refactoring case, which would became undoable only when moving focus to the explorer. Thoughts?

@isidorn
Copy link
Contributor

isidorn commented Dec 2, 2020

@alexdima I see the issue.

I was pondering about this a bit more and my feeling is:

  • The current solution seems to be a bit confusing for the users (since all 3 testers filled some version of "Undo is not working because I have no clue where focus is").
  • Changing the behavior that the Explorer Undoes without it having focus is dangerous as @alexdima also pointed out.
  • Also as @alexdima pointed out: cmd+z from the Editor should not be able to undo operations originating from the explorer. That should at least make the current situaton less confusing - since currently some operations can be undoable and some can not

As I mentioned in other issues, I would probably not change anything here for Endgame, and in Debt week we can decide on a stragety.

My other concern is even if we change the third bullet point I think users will still be confused by undo not working in Explorer since the Explorer passes focus into the editor in some cases automatically.

@alexdima
Copy link
Member

alexdima commented Dec 2, 2020

I agree with you @isidorn . My concern is that we might have to do a recovery build if many people are confused and we might have to live with this until end of January.

We could do the following: undoing from the editor will undo operations inserted by the explorer, but if it hits an undo-redo element inserted by the explorer, it could first prompt to confirm.

@isidorn
Copy link
Contributor

isidorn commented Dec 2, 2020

That sounds like a good approach to me.

@alexdima
Copy link
Member

alexdima commented Dec 2, 2020

This is what the prompt will read for this case:

image

@isidorn
Copy link
Contributor

isidorn commented Dec 2, 2020

Looks good!

I can also fine tune the label from the Explorer.
I currently call it "New a.txt". I am open for suggestions
"Create a.txt"
"create a.txt"

@alexdima
Copy link
Member

alexdima commented Dec 2, 2020

👍 I like "Create a.txt". I just pushed so you can test how it feels, running from source.

@isidorn
Copy link
Contributor

isidorn commented Dec 2, 2020

Feels good to me, just tried it out.

Screenshot 2020-12-02 at 18 00 02

isidorn added a commit that referenced this issue Dec 2, 2020
@isidorn
Copy link
Contributor

isidorn commented Dec 2, 2020

I like the flow, played around it a bit more...

Fyi testers for potential feedback @aeschli @meganrogge @rebornix

Gist of the above discussion: when there is an "aggresive" undo from the editor we now prompt.
What I mean by aggressive is editor undoing something which was intiated from the Explorer.
Also note that we distinguish undos based on where the focus is (as I mentioned in the test plan item)

@aeschli
Copy link
Contributor Author

aeschli commented Dec 3, 2020

Maybe deleting a file (undoing a create, copy, move) should always prompt, regardless if invoked from the editor and explorer.

@isidorn
Copy link
Contributor

isidorn commented Dec 3, 2020

@aeschli makes sense, however you can always redo to bring it back. So for now I would not prompt, but I am open to changing this.

@isidorn
Copy link
Contributor

isidorn commented Jan 18, 2021

I beleive we are good here, since we now also introduced a prompt for destructive operations.
Undoing a create.

I am currently not prompting for undoing a move or copy - since you do not get data loss then. Though I am open to changing that.

Thus closing this

@isidorn isidorn closed this as completed Jan 18, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Mar 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
file-explorer Explorer widget issues under-discussion Issue is under discussion for relevance, priority, approach undo-redo Issues around undo/redo
Projects
None yet
Development

No branches or pull requests

4 participants