Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 837bcfb

Browse files
committed
Make sure TextBuffer.save() calls through to custom files
Released under CC0.
1 parent 07217fb commit 837bcfb

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

spec/text-buffer-io-spec.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,21 @@ describe('TextBuffer IO', () => {
239239
})
240240

241241
describe('when the buffer is backed by a custom File object instead of a path', () => {
242+
let file
243+
242244
beforeEach(() => {
243-
buffer.setFile(new SimpleFile(filePath))
245+
buffer = new TextBuffer()
246+
file = new SimpleFile(filePath)
247+
buffer.setFile(file)
248+
spyOn(file, 'createWriteStream').and.callThrough()
244249
})
245250

246251
it('saves the contents of the buffer to the given file', (done) => {
247252
buffer.setText('abc def ghi jkl\n'.repeat(10 * 1024))
248253
buffer.save().then(() => {
249254
expect(fs.readFileSync(filePath, 'utf8')).toEqual(buffer.getText())
250255
expect(buffer.isModified()).toBe(false)
256+
expect(file.createWriteStream).toHaveBeenCalled()
251257
done()
252258
})
253259
})

src/text-buffer.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,7 @@ class TextBuffer
15391539
#
15401540
# Returns a {Promise} that resolves when the save has completed.
15411541
save: ->
1542-
@saveAs(@getPath())
1542+
@saveTo(@file)
15431543

15441544
# Public: Save the buffer at a specific path.
15451545
#

0 commit comments

Comments
 (0)