From 10ca03f238ce5bbf873b670f483a0041c9a955c3 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 2 May 2013 11:42:12 -0700 Subject: [PATCH] Don't show indent guide in truly trailing whitespace Lines that are all whitespace are considered trailing whitespace and should display the indent guide. But lines with leading and trailing whitespace should never have the indent guide rendered in the trailing area. --- spec/app/editor-spec.coffee | 9 +++++++++ src/app/token.coffee | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index 7a9f98d07..0aca4b840 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -1551,6 +1551,15 @@ 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 the line has leading and trailing whitespace", -> + it "does not display the indent guide in the trailing whitespace", -> + editor.attachToDom() + config.set("editor.showIndentGuide", true) + + editor.insertText("/*\n * \n*/") + expect(editor.renderedLines.find('.line:eq(1) .indent-guide').length).toBe 1 + expect(editor.renderedLines.find('.line:eq(1) .indent-guide')).toHaveClass('leading-whitespace') + describe "when the line is empty and end of show invisibles are enabled", -> it "renders the indent guides interleaved the end of line invisibles", -> editor.attachToDom() diff --git a/src/app/token.coffee b/src/app/token.coffee index 01707dd2d..de78a0457 100644 --- a/src/app/token.coffee +++ b/src/app/token.coffee @@ -92,7 +92,7 @@ class Token "#{match}" if hasTrailingWhitespace classes = [] - classes.push('indent-guide') if hasIndentGuide + classes.push('indent-guide') if hasIndentGuide and not hasLeadingWhitespace classes.push('invisible-character') if invisibles.space classes.push('trailing-whitespace') classes = classes.join(' ')