diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee
index 04241fae6..25dc557dc 100644
--- a/spec/app/editor-spec.coffee
+++ b/spec/app/editor-spec.coffee
@@ -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)
diff --git a/src/app/editor.coffee b/src/app/editor.coffee
index 775963830..7aed2b006 100644
--- a/src/app/editor.coffee
+++ b/src/app/editor.coffee
@@ -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("#{invisibles.cr}")
- if invisibles.eol and not screenLine.isSoftWrapped()
+ if invisibles.eol
line.push("#{invisibles.eol}")
line.push('')
diff --git a/src/app/screen-line.coffee b/src/app/screen-line.coffee
index 2d01a07b1..a590d8e86 100644
--- a/src/app/screen-line.coffee
+++ b/src/app/screen-line.coffee
@@ -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]