mirror of
https://github.com/atom/atom.git
synced 2026-01-24 06:18:03 -05:00
Add Buffer.isEmpty()
To be used by Buffer.isModified() for when the buffer has no backing file
This commit is contained in:
@@ -650,3 +650,16 @@ describe 'Buffer', ->
|
||||
expect(buffer.usesSoftTabs()).toBeFalsy()
|
||||
buffer.setText("")
|
||||
expect(buffer.usesSoftTabs()).toBeUndefined()
|
||||
|
||||
describe ".isEmpty()", ->
|
||||
it "returns true for an empty buffer", ->
|
||||
buffer.setText('')
|
||||
expect(buffer.isEmpty()).toBeTruthy()
|
||||
|
||||
it "returns false for a non-empty buffer", ->
|
||||
buffer.setText('a')
|
||||
expect(buffer.isEmpty()).toBeFalsy()
|
||||
buffer.setText('a\nb\nc')
|
||||
expect(buffer.isEmpty()).toBeFalsy()
|
||||
buffer.setText('\n')
|
||||
expect(buffer.isEmpty()).toBeFalsy()
|
||||
|
||||
@@ -244,10 +244,12 @@ class Buffer
|
||||
if @file
|
||||
@memoryContentSignature != @diskContentSignature
|
||||
else
|
||||
@lines.length > 1 or @lines[0]
|
||||
not @isEmpty()
|
||||
|
||||
isInConflict: -> @conflict
|
||||
|
||||
isEmpty: -> @lines.length is 1 and @lines[0].length is 0
|
||||
|
||||
getAnchors: -> new Array(@anchors...)
|
||||
|
||||
addAnchor: (options) ->
|
||||
|
||||
Reference in New Issue
Block a user