Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions spec/text-buffer-io-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,13 @@ describe('TextBuffer IO', () => {
expect(buffer.isInConflict()).toBe(true)
await buffer.save()
expect(buffer.isInConflict()).toBe(false)
// Ensure we don't get flipped into conflicted status after the
// `onDidChange` handler comes through…
await wait(1000)
expect(buffer.isInConflict()).toBe(false)
buffer.setText('q')
// …and the buffer is modified again.
expect(buffer.isInConflict()).toBe(false)
done()
})
})
Expand Down
11 changes: 11 additions & 0 deletions src/text-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2273,9 +2273,20 @@ class TextBuffer {
if (this.isModified()) {
const source = this.file.getPath()
if (!(await this.buffer.baseTextMatchesFile(source, this.getEncoding()))) {
// Emit `did-conflict` and take no other action. We will keep the
// current buffer contents so that the user's changes are not lost.
this.emitter.emit('did-conflict')
} else {
// Despite being modified, we're once again in alignment with what
// is on disk. This file is not in conflict.
this.fileHasChangedSinceLastLoad = false
}
} else {
// This buffer was previously in sync with what was on disk, so we
// can update its contents to match the new contents on disk. By
// definition, this means there is no conflict, so we'll reset the
// appropriate flag.
this.fileHasChangedSinceLastLoad = false
return this.load({internal: true})
}
}, this.fileChangeDelay)))
Expand Down
Loading