mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Disable buffer modified indicator if buffer content matches content on disk
This commit is contained in:
@@ -47,13 +47,24 @@ describe "StatusBar", ->
|
||||
expect(statusBar.currentPath.text()).toBe 'sample.txt'
|
||||
|
||||
describe "when the associated editor's buffer's content changes", ->
|
||||
it "updates the buffer modified indicator", ->
|
||||
it "enables the buffer modified indicator", ->
|
||||
expect(statusBar.bufferModified.text()).toBe ''
|
||||
oldText = buffer.getText()
|
||||
editor.insertText("/")
|
||||
editor.insertText("\n")
|
||||
expect(statusBar.bufferModified.text()).toBe '*'
|
||||
editor.backspace()
|
||||
|
||||
describe "when the buffer content has changed from the content on disk", ->
|
||||
it "disables the buffer modified indicator on save", ->
|
||||
editor.insertText("\n")
|
||||
editor.save()
|
||||
expect(statusBar.bufferModified.text()).toBe ''
|
||||
editor.backspace()
|
||||
editor.save()
|
||||
|
||||
it "disables the buffer modified indicator if the content matches again", ->
|
||||
editor.insertText("\n")
|
||||
expect(statusBar.bufferModified.text()).toBe '*'
|
||||
editor.backspace()
|
||||
buffer.save()
|
||||
expect(statusBar.bufferModified.text()).toBe ''
|
||||
|
||||
describe "when the associated editor's cursor position changes", ->
|
||||
|
||||
@@ -248,6 +248,9 @@ class Buffer
|
||||
isModified: ->
|
||||
@modified
|
||||
|
||||
contentDifferentOnDisk: ->
|
||||
fs.read(@file.getPath()) != @getText()
|
||||
|
||||
getAnchors: -> new Array(@anchors...)
|
||||
|
||||
addAnchor: (options) ->
|
||||
|
||||
@@ -33,7 +33,8 @@ class StatusBar extends View
|
||||
@editor.getBuffer().on 'buffer-change', => @updateBufferModifiedText()
|
||||
|
||||
updateBufferModifiedText: ->
|
||||
if @editor.getBuffer().isModified()
|
||||
buffer = @editor.getBuffer()
|
||||
if buffer.isModified() and buffer.contentDifferentOnDisk()
|
||||
@bufferModified.text('*')
|
||||
else
|
||||
@bufferModified.text('')
|
||||
|
||||
Reference in New Issue
Block a user