Only render an nbsp on empty lines when no eol character defined

Fixes #3053
This commit is contained in:
Ben Ogle 2014-07-23 09:30:52 -07:00
parent f5f9de1bf8
commit ffb041a160
2 changed files with 18 additions and 4 deletions

View File

@ -192,6 +192,10 @@ describe "EditorComponent", ->
for lineNode in lineNodes
expect(lineNode.style.width).toBe scrollViewWidth + 'px'
it "renders an nbsp on empty lines when no line-ending character is defined", ->
atom.config.set("editor.showInvisibles", false)
expect(component.lineNodeForScreenRow(10).textContent).toBe nbsp
describe "when showInvisibles is enabled", ->
invisibles = null
@ -232,7 +236,15 @@ describe "EditorComponent", ->
expect(component.lineNodeForScreenRow(0).textContent).toBe "a line that ends with a carriage return#{invisibles.cr}#{invisibles.eol}"
it "renders invisible line-ending characters on empty lines", ->
expect(component.lineNodeForScreenRow(10).textContent).toBe nbsp + invisibles.eol
expect(component.lineNodeForScreenRow(10).textContent).toBe invisibles.eol
it "renders an nbsp on empty lines when the line-ending character is an empty string", ->
atom.config.set("editor.invisibles", eol: '')
expect(component.lineNodeForScreenRow(10).textContent).toBe nbsp
it "renders an nbsp on empty lines when no line-ending character is defined", ->
atom.config.set("editor.invisibles", eol: null)
expect(component.lineNodeForScreenRow(10).textContent).toBe nbsp
it "interleaves invisible line-ending characters with indent guides on empty lines", ->
component.setShowIndentGuide(true)

View File

@ -181,7 +181,7 @@ LinesComponent = React.createClass
lineHTML
else
' ' + @buildEndOfLineHTML(line, @props.invisibles)
@buildEndOfLineHTML(line, @props.invisibles) or ' '
buildLineInnerHTML: (line) ->
{invisibles, mini, showIndentGuide, invisibles} = @props
@ -204,9 +204,11 @@ LinesComponent = React.createClass
return '' if @props.mini or line.isSoftWrapped()
html = ''
if invisibles.cr? and line.lineEnding is '\r\n'
# Note the lack of '?' in the character checks. A user can set the chars
# to an empty string which we will interpret as not-set
if invisibles.cr and line.lineEnding is '\r\n'
html += "<span class='invisible-character'>#{invisibles.cr}</span>"
if invisibles.eol?
if invisibles.eol
html += "<span class='invisible-character'>#{invisibles.eol}</span>"
html