Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Handle deleted files correctly #1271

Merged
merged 19 commits into from
Dec 12, 2013
Merged

Conversation

probablycorey
Copy link

Previously, if a file was open in Atom but deleted from the command line (or git, etc...) Atom would keep that buffer open and mark it as modified. This was annoying because when closing Atom it would prompt to be saved. This PR makes Atom treat deleted files as unmodified (unless the file was modified prior to deletion.)

One caveat still exists. The edit session for the deleted file will still be serialized. So a file that doesn't exist on disk will persist when you restart Atom until you explicitly close it. I'd like to wait and fix this problem after we decide on the future of panes.

Created to solve #693

@@ -77,6 +78,9 @@ class Project extends telepath.Model
destroyUnretainedBuffers: ->
buffer.destroy() for buffer in @getBuffers() when not buffer.isRetained()

destroyNonExistentNonModified: ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about destroyUnmodifiedNonExistentBuffers?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it much better.

@@ -117,8 +117,8 @@ class TextBuffer extends telepath.Model
@reload()

@file.on "removed", =>
@updateCachedDiskContents().done =>
@emitModifiedStatusChanged(@isModified())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this emitModifiedStatusChanged line moved somewhere else? Just wondering if we still needed it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it now maintains the modified status of the file emitModifiedStatusChanged isn't needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🆒

@probablycorey
Copy link
Author

I added some 🆕 behavior. If an unmodified buffer is deleted, Atom will remove all editors for that buffer.

@@ -421,6 +421,17 @@ describe "Pane", ->
view2.trigger 'title-changed'
expect(activeItemTitleChangedHandler).toHaveBeenCalled()

describe "when an unmodifed buffer's path is deleted its pane item is removed", ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can kill the its pane item is removed from this since it is covered in the it, right? 👇

@nathansobo
Copy link
Contributor

I notice these specs pop up a lot of dialogs when I run them for some reason.

@state = atom.site.createDocument
deserializer: 'Pane'
items: @items.map (item) -> item.getState?() ? item.serialize()
items: items.map (item) -> item.getState?() ? item.serialize()
items.forEach (item) => @addItem(item, @items.length)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worried items are going to end up in the state twice here... maybe you should create the state with an empty array and then add them all?

probablycorey pushed a commit that referenced this pull request Dec 12, 2013
@probablycorey probablycorey merged commit 5d23a8f into master Dec 12, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants