From 908a2978aee1850fd0390f48cb0270d1a2b23610 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Thu, 19 Jun 2014 14:20:32 -0700 Subject: [PATCH 1/2] =?UTF-8?q?Don=E2=80=99t=20render=20decorations=20on?= =?UTF-8?q?=20the=20last=20empty=20line=20when=20selection=20not=20empty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/editor-component-spec.coffee | 12 ++++++++++-- src/editor-component.coffee | 6 +++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/spec/editor-component-spec.coffee b/spec/editor-component-spec.coffee index de7439917..966af75a7 100644 --- a/spec/editor-component-spec.coffee +++ b/spec/editor-component-spec.coffee @@ -439,7 +439,7 @@ describe "EditorComponent", -> expect(lineNumberHasClass(10, 'cursor-line')).toBe false it "adds cursor-line decorations to multiple lines when a selection is performed", -> - cursor.setScreenPosition([1, 0]) + cursor.setScreenPosition([1, 5]) editor.selectDown(2) expect(lineNumberHasClass(0, 'cursor-line')).toBe false expect(lineNumberHasClass(1, 'cursor-line')).toBe true @@ -447,10 +447,18 @@ describe "EditorComponent", -> expect(lineNumberHasClass(3, 'cursor-line')).toBe true expect(lineNumberHasClass(4, 'cursor-line')).toBe false + it "does not render a curslor-line decoration for the last empty selected line in a multiline selection", -> + cursor.setScreenPosition([1, 0]) + editor.selectDown(2) + expect(lineNumberHasClass(0, 'cursor-line')).toBe false + expect(lineNumberHasClass(1, 'cursor-line')).toBe true + expect(lineNumberHasClass(2, 'cursor-line')).toBe true + expect(lineNumberHasClass(3, 'cursor-line')).toBe false + describe "when decorations are applied to markers", -> {marker, decoration} = {} beforeEach -> - marker = editor.displayBuffer.markBufferRange([[2, 13], [3, 15]], class: 'my-marker', invalidate: 'inside') + marker = editor.displayBuffer.markBufferRange([[2, 13], [3, 15]], invalidate: 'inside') decoration = {type: 'gutter', class: 'someclass'} editor.addDecorationForMarker(marker, decoration) waitsFor -> not component.decorationChangedImmediate? diff --git a/src/editor-component.coffee b/src/editor-component.coffee index 7398f7632..129bf60bf 100644 --- a/src/editor-component.coffee +++ b/src/editor-component.coffee @@ -236,9 +236,13 @@ EditorComponent = React.createClass for decoration in decorations if editor.decorationMatchesType(decoration, 'gutter') or editor.decorationMatchesType(decoration, 'line') screenRange ?= marker.getScreenRange() - for screenRow in [screenRange.start.row..screenRange.end.row] + startRow = screenRange.start.row + endRow = screenRange.end.row + endRow-- if not screenRange.isEmpty() and screenRange.end.column == 0 + for screenRow in [startRow..endRow] decorationsByScreenRow[screenRow] ?= [] decorationsByScreenRow[screenRow].push decoration + decorationsByScreenRow getHighlightDecorations: (decorationsByMarkerId) -> From 520ece4b132f697871b12d4574d843676adef1b1 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Thu, 19 Jun 2014 15:09:49 -0700 Subject: [PATCH 2/2] :lipstick: Wording --- spec/editor-component-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/editor-component-spec.coffee b/spec/editor-component-spec.coffee index 966af75a7..1f1f57bab 100644 --- a/spec/editor-component-spec.coffee +++ b/spec/editor-component-spec.coffee @@ -447,7 +447,7 @@ describe "EditorComponent", -> expect(lineNumberHasClass(3, 'cursor-line')).toBe true expect(lineNumberHasClass(4, 'cursor-line')).toBe false - it "does not render a curslor-line decoration for the last empty selected line in a multiline selection", -> + it "does not render a cursor-line decoration for the last line of a multi-line selection of the selection ends at column 0", -> cursor.setScreenPosition([1, 0]) editor.selectDown(2) expect(lineNumberHasClass(0, 'cursor-line')).toBe false