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

Two similar local history entries show up on renaming a file #145881

Closed
karrtikr opened this issue Mar 23, 2022 · 5 comments
Closed

Two similar local history entries show up on renaming a file #145881

karrtikr opened this issue Mar 23, 2022 · 5 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders polish Cleanup and polish issue timeline-local-history verified Verification succeeded
Milestone

Comments

@karrtikr
Copy link
Contributor

karrtikr commented Mar 23, 2022

Testing #145461

image

  • The first entry shows up when I rename a file via explorer.
  • The second entry shows up when I save the file without any edit. (Even though it's already saved via rename)

Both the entries are actually the same.

@bpasero
Copy link
Member

bpasero commented Mar 23, 2022

Yeah, I forgot that refactoring might also trigger a file rename operation and then we have competing listeners. I should probably install some mergeWindow for this particular case even when the history sources differ.

@bpasero bpasero added polish Cleanup and polish issue timeline-local-history labels Mar 23, 2022
@bpasero bpasero added this to the March 2022 milestone Mar 23, 2022
@bpasero
Copy link
Member

bpasero commented Mar 23, 2022

@karrtikr qq: how did you trigger that refactoring?

@karrtikr
Copy link
Contributor Author

I simply renamed the file via the file explorer. The file was renamed and saved automatically. But then I pressed CTRL+S to save again. That triggered the second entry.

@bpasero bpasero added the bug Issue identified by VS Code Team member as probable bug label Mar 24, 2022
@bpasero
Copy link
Member

bpasero commented Mar 24, 2022

This was a bit complicate to fix, but here is what we do:

  • when you save an editor, we check if we previously had added a history entry for the content version of the editor to prevent adding history entries over and over for each save you press
  • the content version of an editor is just a counter that increments each time the content of an editor changes
  • in this case this check fails because the entry that is added to history from the rename operation does not originate from a normal save of the editor but from a rename in the file explorer
  • the fix is to handle the file rename similar to a save and record the content version at the time of the rename so that when you hit save again after rename and the content version did not change, the history entry is ignored

Verification:

  • test the steps as outlined above
  • also test that when you modify the file again after rename and save, the history entry appears as normal

@karrtikr karrtikr added verification-needed Verification of issue is requested and removed verification-needed Verification of issue is requested labels Mar 24, 2022
@karrtikr
Copy link
Contributor Author

Yep seems to be working now.

@karrtikr karrtikr added the verified Verification succeeded label Mar 24, 2022
@github-actions github-actions bot locked and limited conversation to collaborators May 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders polish Cleanup and polish issue timeline-local-history verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

3 participants
@bpasero @karrtikr and others