Unmodified buffer updates contents when file changes outside of atom.

This commit is contained in:
Corey Johnson
2012-06-28 13:02:21 -07:00
parent 6182cf4736
commit 8e7a8836cd
2 changed files with 34 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
_ = require 'underscore'
fs = require 'fs'
File = require 'file'
Point = require 'point'
Range = require 'range'
EventEmitter = require 'event-emitter'
@@ -10,7 +11,8 @@ class Buffer
@idCounter = 1
modified: null
lines: null
path: null
file: null
constructor: (path) ->
@id = @constructor.idCounter++
@@ -24,7 +26,7 @@ class Buffer
@modified = false
getPath: ->
@path
@file.getPath()
getExtension: ->
if @getPath()
@@ -33,7 +35,9 @@ class Buffer
null
setPath: (path) ->
@path = path
@file = new File(path)
@file.on "contents-change", =>
@setText(fs.read(@file.getPath())) unless @isModified()
@trigger "path-change", this
getText: ->