Skip to content

Fix issue where isDeleted incorrectly returned true#15

Open
savetheclocktower wants to merge 2 commits into
masterfrom
fix-is-deleted-on-new-buffer-with-path
Open

Fix issue where isDeleted incorrectly returned true#15
savetheclocktower wants to merge 2 commits into
masterfrom
fix-is-deleted-on-new-buffer-with-path

Conversation

@savetheclocktower
Copy link
Copy Markdown

…when a buffer is newly created and set to a path that does not yet exist on disk.

This is something I screwed up on #13. To track a buffer’s “deleted” state — meaning “is not currently backed by a file on disk, but was at one point” — we keep a didHaveFileOnDisk property and change it as needed.

In TextBuffer::load, I unconditionally set

this.didHaveFileOnDisk = true

because I suppose I thought that the load method would always be loading a file from disk. But there are use cases for calling load when the buffer’s file instance is set to a nonexistent path.

let someBuffer = TextBuffer.load('nonexistent.txt')

The above snippet creates a new buffer much the way it would if you'd simply said new TextBuffer — but it already knows where it will save once you ask it to save itself. So in TextBuffer::load (called by the static TextBuffer.load) we must set didHaveFileOnDisk based on whether the file actually exists instead of assuming true.

Easy to modify an existing spec to do a sanity-check here.

This is why pulsar#1588 is still in draft; this regression caused an autosave spec to fail. Gotta land this fix and then bump text-buffer again before that PR is ready to come out of draft.

…when a buffer is newly created and set to a path that does not yet exist on disk.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant