Cache content after file is written successfully.

This commit is contained in:
Cheng Zhao
2014-02-11 15:01:14 +08:00
parent 84ee94dfd1
commit d0fe2c9a5b
2 changed files with 3 additions and 3 deletions

View File

@@ -61,8 +61,8 @@ class File
# Public: Overwrites the file with the given String.
write: (text) ->
previouslyExisted = @exists()
@cachedContents = text
@writeFileWithPrivilegeEscalationSync(@getPath(), text)
@cachedContents = text
@subscribeToNativeChangeEvents() if not previouslyExisted and @hasSubscriptions()
# Deprecated
@@ -132,7 +132,7 @@ class File
fs.writeFileSync(path, text)
catch error
if error.code is 'EACCES' and process.platform is 'darwin'
authopen = '/usr/libexec/authopen' # man 1 auth open
authopen = '/usr/libexec/authopen' # man 1 authopen
unless runas(authopen, ['-w', '-c', path], stdin: text) is 0
throw error
else

View File

@@ -194,8 +194,8 @@ class TextBuffer extends TextBufferCore
@emit 'will-be-saved', this
@setPath(path)
@cachedDiskContents = @getText()
@file.write(@getText())
@cachedDiskContents = @getText()
@emitModifiedStatusChanged(false)
@emit 'saved', this