Don't add CR invisible if line is soft wrapped

This commit is contained in:
Kevin Sawicki 2013-01-28 13:33:46 -08:00
parent fa5ceedfe0
commit d84c600679
3 changed files with 19 additions and 2 deletions

View File

@ -1632,6 +1632,21 @@ describe "Editor", ->
expect(editor.renderedLines.find('.line:first').text()).toBe "a line#{space}"
expect(editor.renderedLines.find('.line:last').text()).toBe "wraps#{eol}"
it "displays trailing carriage return using a visible non-empty value", ->
editor.setSoftWrapColumn(6)
editor.setText "a line that\r\n"
editor.attachToDom()
config.set "editor.showInvisibles", true
space = editor.invisibles?.space
expect(space).toBeTruthy()
cr = editor.invisibles?.cr
expect(cr).toBeTruthy()
eol = editor.invisibles?.eol
expect(eol).toBeTruthy()
expect(editor.renderedLines.find('.line:first').text()).toBe "a line#{space}"
expect(editor.renderedLines.find('.line:eq(1)').text()).toBe "that#{cr}#{eol}"
expect(editor.renderedLines.find('.line:last').text()).toBe "#{eol}"
describe "gutter rendering", ->
beforeEach ->
editor.attachToDom(heightInLines: 5.5)

View File

@ -1076,10 +1076,10 @@ class Editor extends View
position += token.value.length
popScope() while scopeStack.length > 0
if invisibles and not @mini
if invisibles and not @mini and not screenLine.isSoftWrapped()
if invisibles.cr and screenLine.lineEnding is '\r\n'
line.push("<span class='invisible'>#{invisibles.cr}</span>")
if invisibles.eol and not screenLine.isSoftWrapped()
if invisibles.eol
line.push("<span class='invisible'>#{invisibles.eol}</span>")
line.push('</pre>')

View File

@ -74,11 +74,13 @@ class ScreenLine
bufferRows: 0
startBufferColumn: @startBufferColumn
ruleStack: @ruleStack
lineEnding: @lineEnding
)
rightFragment = new ScreenLine(
tokens: rightTokens
startBufferColumn: @startBufferColumn + column
ruleStack: @ruleStack
lineEnding: @lineEnding
)
[leftFragment, rightFragment]