mirror of
https://github.com/atom/atom.git
synced 2026-01-24 06:18:03 -05:00
Buffer.save only writes to disk if the buffer is modified
This prevents autosave from writing unmodified buffers to disk, which was causing the tree view to rebuild directory contents based on the write event just when switching tabs.
This commit is contained in:
@@ -337,6 +337,7 @@ describe 'Buffer', ->
|
||||
filePath = '/tmp/temp.txt'
|
||||
fs.write(filePath, "")
|
||||
saveBuffer = new Buffer filePath
|
||||
saveBuffer.setText("blah")
|
||||
|
||||
it "saves the contents of the buffer to the path", ->
|
||||
saveBuffer.setText 'Buffer contents!'
|
||||
@@ -370,6 +371,7 @@ describe 'Buffer', ->
|
||||
describe "when the buffer has no path", ->
|
||||
it "throws an exception", ->
|
||||
saveBuffer = new Buffer
|
||||
saveBuffer.setText "hi"
|
||||
expect(-> saveBuffer.save()).toThrow()
|
||||
|
||||
describe "reload()", ->
|
||||
|
||||
@@ -238,7 +238,7 @@ class Buffer
|
||||
@undoManager.redo(editSession)
|
||||
|
||||
save: ->
|
||||
@saveAs(@getPath())
|
||||
@saveAs(@getPath()) if @isModified()
|
||||
|
||||
saveAs: (path) ->
|
||||
unless path then throw new Error("Can't save buffer with no file path")
|
||||
|
||||
Reference in New Issue
Block a user