Skip to content

Commit

Permalink
writeSync emits did-change event
Browse files Browse the repository at this point in the history
Co-Authored-By: kenny <[email protected]>
  • Loading branch information
aminya and heavyk committed Nov 12, 2020
1 parent f062e34 commit 35d5685
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions spec/file-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -506,3 +506,10 @@ describe 'File', ->
readHandler.callCount > 0
runs ->
expect(readHandler.argsForCall[0][0]).toBe(null)

describe 'writeSync()', ->
it 'emits did-change event', ->
file.onDidChange writeHandler = jasmine.createSpy('write handler')
file.writeSync('ok')
waitsFor 'write handler', ->
writeHandler.callCount > 0
2 changes: 2 additions & 0 deletions src/file.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ class File
@writeFileSync(@getPath(), text)
@cachedContents = text
@setDigest(text)
@emit 'contents-changed' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change'
@subscribeToNativeChangeEvents() if not previouslyExisted and @hasSubscriptions()
undefined

Expand Down

0 comments on commit 35d5685

Please sign in to comment.