Skip to content

Fix issue where isDeleted incorrectly returned true - #15

Merged
savetheclocktower merged 3 commits into
masterfrom
fix-is-deleted-on-new-buffer-with-path
Sep 10, 2026
Merged

Fix issue where isDeleted incorrectly returned true#15
savetheclocktower merged 3 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.
@savetheclocktower

Copy link
Copy Markdown
Author

Bump! Officially thinking about landing this even in the absence of a review. Might add a few more tests for safety's sake first.

@pulsar-edit pulsar-edit deleted a comment from ottok Sep 7, 2026
@savetheclocktower
savetheclocktower merged commit 66e19ce into master Sep 10, 2026
2 checks passed
@savetheclocktower
savetheclocktower deleted the fix-is-deleted-on-new-buffer-with-path branch September 10, 2026 07:03
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