Add the ability to trigger “resurrection” logic…#17
Draft
savetheclocktower wants to merge 3 commits into
Draft
Conversation
…when a buffer is newly created and set to a path that does not yet exist on disk.
…to make it easier for other tools to tell us when one of our `isDeleted()` buffers has been resurrected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…to make it easier for other tools to tell us when one of our
isDeleted()buffers has been resurrected.(This PR will stay in draft until #15 lands.)
This PR implements what is described in #16. Since we don't have the tools to detect on our own exactly when a deleted file becomes un-deleted, we will instead expose an imperative method called
resurrectthat will do all the things we would do if we could simply attach anonDidUndeletehandler somewhere.Pulsar already imports
watchPath(our recursive file-watching library) intosrc/project.js. We can set up a listener on each project root whose logic looks a bit like this:TextBuffer::resurrect()The new logic in specs tests two different deleted-and-resurrected scenarios: one where the buffer has uncommitted changes and another where it doesn't. The latter is the simpler case, of course. In the former scenario, we can detect the conflict when the buffer reload fails to work as expected and transition to a “conflicted” state.
I've also added a couple of methods to make our lives easier on the consumer side. We had
onDidConflictandonDidDelete, but those imply that transitioning into a “conflicted” or “deleted” status is a one-way operation. We already hadonDidChangeModified, so I addedonDidChangeConflictedandonDidChangeDeletedin the same style.The
tabspackage will prefer these new callback methods if they exist, but will fall back toonDidConflictandonDidDeleteif they have to.