Render line-ending invisibles on empty lines

Fixes #2857

Including correct interleaving with indent guides.
This commit is contained in:
Nathan Sobo
2014-07-08 16:51:41 -06:00
parent 2602e6ec0a
commit e170b9f56b
3 changed files with 46 additions and 5 deletions

View File

@@ -232,6 +232,28 @@ describe "EditorComponent", ->
runSetImmediateCallbacks()
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 invisibles.eol
it "interleaves invisible line-ending characters with indent guides on empty lines", ->
component.setShowIndentGuide(true)
editor.setTextInBufferRange([[10, 0], [11, 0]], "\r\n", false)
runSetImmediateCallbacks()
expect(component.lineNodeForScreenRow(10).innerHTML).toBe '<span class="indent-guide"><span class="invisible-character">C</span><span class="invisible-character">E</span></span>'
editor.setTabLength(3)
runSetImmediateCallbacks()
expect(component.lineNodeForScreenRow(10).innerHTML).toBe '<span class="indent-guide"><span class="invisible-character">C</span><span class="invisible-character">E</span> </span>'
editor.setTabLength(1)
runSetImmediateCallbacks()
expect(component.lineNodeForScreenRow(10).innerHTML).toBe '<span class="indent-guide"><span class="invisible-character">C</span></span><span class="indent-guide"><span class="invisible-character">E</span></span>'
editor.setTextInBufferRange([[9, 0], [9, Infinity]], ' ')
editor.setTextInBufferRange([[11, 0], [11, Infinity]], ' ')
runSetImmediateCallbacks()
expect(component.lineNodeForScreenRow(10).innerHTML).toBe '<span class="indent-guide"><span class="invisible-character">C</span></span><span class="invisible-character">E</span>'
describe "when soft wrapping is enabled", ->
beforeEach ->
editor.setText "a line that wraps "