diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index d30a3b3f2..a9cf99230 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -1863,6 +1863,19 @@ describe "Editor", -> expect(editor.renderedLines.find('.line:eq(10) .indent-guide').length).toBe 2 expect(editor.renderedLines.find('.line:eq(10) .indent-guide').text()).toBe ' ' + describe "when a line contains only whitespace", -> + it "displays an indent guide on the line", -> + editor.attachToDom() + config.set("editor.showIndentGuide", true) + + editor.setCursorBufferPosition([10]) + editor.indent() + console.log 'here' + editor.indent() + expect(editor.getCursorBufferPosition()).toEqual [10, 4] + expect(editor.renderedLines.find('.line:eq(10) .indent-guide').length).toBe 2 + expect(editor.renderedLines.find('.line:eq(10) .indent-guide').text()).toBe ' ' + describe "gutter rendering", -> beforeEach -> editor.attachToDom(heightInLines: 5.5) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 3631e1cd6..b85c88479 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -1201,16 +1201,14 @@ class Editor extends View else firstNonWhitespacePosition = screenLine.text.search(/\S/) firstTrailingWhitespacePosition = screenLine.text.search(/\s*$/) + lineIsWhitespaceOnly = firstTrailingWhitespacePosition is 0 position = 0 for token in screenLine.tokens updateScopeStack(token.scopes) - line.push(token.getValueAsHtml( - invisibles: invisibles - hasLeadingWhitespace: position < firstNonWhitespacePosition - hasTrailingWhitespace: position + token.value.length > firstTrailingWhitespacePosition - hasIndentGuide: @showIndentGuide - )) - + hasLeadingWhitespace = position < firstNonWhitespacePosition + hasTrailingWhitespace = position + token.value.length > firstTrailingWhitespacePosition + hasIndentGuide = @showIndentGuide and (hasLeadingWhitespace or lineIsWhitespaceOnly) + line.push(token.getValueAsHtml({invisibles, hasLeadingWhitespace, hasTrailingWhitespace, hasIndentGuide})) position += token.value.length popScope() while scopeStack.length > 0 diff --git a/src/app/token.coffee b/src/app/token.coffee index fa3f0dc6b..1bcd45660 100644 --- a/src/app/token.coffee +++ b/src/app/token.coffee @@ -92,6 +92,7 @@ class Token html = html.replace /[ ]+$/, (match) -> classes = [] classes.push('invisible') if invisibles.space + classes.push('indent-guide') if hasIndentGuide classes.push('trailing-whitespace') match = match.replace(/./g, invisibles.space) if invisibles.space "#{match}"