From a4ad5829a56dd7d27f4e6af561e133606b96003c Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 28 Sep 2012 19:19:43 -0700 Subject: [PATCH] Disable gutter background highlight on multiline selections --- spec/app/editor-spec.coffee | 17 ++++++++++++++--- src/app/gutter.coffee | 11 +++++++++-- static/editor.css | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index d32b05f90..a3cd1add7 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -1609,14 +1609,25 @@ describe "Editor", -> it "highlights the line where the initial cursor position is", -> expect(editor.getCursorBufferPosition().row).toBe 0 - expect(editor.find('.line-number.cursor-line-number').length).toBe 1 - expect(editor.find('.line-number.cursor-line-number').text()).toBe "1" + expect(editor.find('.line-number.cursor-line-number.cursor-line-number-background').length).toBe 1 + expect(editor.find('.line-number.cursor-line-number.cursor-line-number-background').text()).toBe "1" it "updates the highlighted line when the cursor position changes", -> editor.setCursorBufferPosition([1,0]) expect(editor.getCursorBufferPosition().row).toBe 1 + expect(editor.find('.line-number.cursor-line-number.cursor-line-number-background').length).toBe 1 + expect(editor.find('.line-number.cursor-line-number.cursor-line-number-background').text()).toBe "2" + + describe "when the selection spans multiple lines", -> + beforeEach -> + editor.attachToDom(30) + + it "doesn't highlight the backround", -> + editor.getSelection().setBufferRange(new Range([0,0],[2,0])) + expect(editor.getSelection().isMultiLine()).toBe true expect(editor.find('.line-number.cursor-line-number').length).toBe 1 - expect(editor.find('.line-number.cursor-line-number').text()).toBe "2" + expect(editor.find('.line-number.cursor-line-number.cursor-line-number-background').length).toBe 0 + expect(editor.find('.line-number.cursor-line-number').text()).toBe "3" describe "line highlighting", -> beforeEach -> diff --git a/src/app/gutter.coffee b/src/app/gutter.coffee index e9eccba9b..ef6f744e0 100644 --- a/src/app/gutter.coffee +++ b/src/app/gutter.coffee @@ -60,5 +60,12 @@ class Gutter extends View highlightCursorLine: -> cursorScreenRow = @editor().getCursorScreenPosition().row screenRowIndex = cursorScreenRow - @firstScreenRow - @find(".line-number.cursor-line-number").removeClass('cursor-line-number') - @find(".line-number:eq(#{screenRowIndex})").addClass('cursor-line-number') + + currentLineNumberRow = @find(".line-number.cursor-line-number") + currentLineNumberRow.removeClass('cursor-line-number') + currentLineNumberRow.removeClass('cursor-line-number-background') + + newLineNumberRow = @find(".line-number:eq(#{screenRowIndex})") + newLineNumberRow.addClass('cursor-line-number') + if !@editor().getSelection().isMultiLine() + newLineNumberRow.addClass('cursor-line-number-background') diff --git a/static/editor.css b/static/editor.css index b79ae8909..54b1284e5 100644 --- a/static/editor.css +++ b/static/editor.css @@ -33,7 +33,7 @@ color: rgba(255, 255, 255, .6); } -.line.cursor-line, .line-number.cursor-line-number { +.line.cursor-line, .line-number.cursor-line-number-background { background-color: rgba(255, 255, 255, .12); }