From a513cf260c56df57488b32ad338b36840b63e1f0 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 21 Jan 2015 16:01:03 -0700 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20apply=20line=20decorations=20to?= =?UTF-8?q?=20last=20line=20if=20it=20ends=20at=20column=200?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/text-editor-presenter-spec.coffee | 31 ++++++++++++-------------- src/text-editor-presenter.coffee | 2 ++ 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/spec/text-editor-presenter-spec.coffee b/spec/text-editor-presenter-spec.coffee index f0dbf0f33..01cc0f625 100644 --- a/spec/text-editor-presenter-spec.coffee +++ b/spec/text-editor-presenter-spec.coffee @@ -190,18 +190,6 @@ describe "TextEditorPresenter", -> expect(lineStateForScreenRow(presenter, 0).endOfLineInvisibles).toEqual [atom.config.get('editor.invisibles.eol')] expect(lineStateForScreenRow(presenter, 1).endOfLineInvisibles).toEqual [atom.config.get('editor.invisibles.cr'), atom.config.get('editor.invisibles.eol')] - it "includes .decorationClasses in the line state", -> - editor.decorateMarker(editor.markBufferRange([[4, 0], [6, 0]]), type: 'line', class: 'a') - editor.decorateMarker(editor.markBufferRange([[5, 0], [5, 0]]), type: 'line', class: 'b') - - presenter = new TextEditorPresenter(model: editor, clientHeight: 130, scrollTop: 0, lineHeight: 10, lineOverdrawMargin: 0) - - expect(lineStateForScreenRow(presenter, 3).decorationClasses).toBeNull() - expect(lineStateForScreenRow(presenter, 4).decorationClasses).toEqual ['a'] - expect(lineStateForScreenRow(presenter, 5).decorationClasses).toEqual ['a', 'b'] - expect(lineStateForScreenRow(presenter, 6).decorationClasses).toEqual ['a'] - expect(lineStateForScreenRow(presenter, 7).decorationClasses).toBeNull() - describe "when ::scrollTop changes", -> it "updates the lines that are visible on screen", -> presenter = new TextEditorPresenter(model: editor, clientHeight: 25, scrollTop: 0, lineHeight: 10, lineOverdrawMargin: 1) @@ -273,12 +261,12 @@ describe "TextEditorPresenter", -> tokens: line3.tokens } - describe "when line decorations are added, updated, or destroyed", -> - it "updates the .decorationClasses of the relevant lines", -> - marker1 = editor.markBufferRange([[4, 0], [6, 0]], invalidate: 'touch') + describe ".decorationClasses in line state", -> + it "adds decoration classes to the relevant line state objects, both initially and when decorations change", -> + marker1 = editor.markBufferRange([[4, 0], [6, 2]], invalidate: 'touch') decoration1 = editor.decorateMarker(marker1, type: 'line', class: 'a') presenter = new TextEditorPresenter(model: editor, clientHeight: 130, scrollTop: 0, lineHeight: 10, lineOverdrawMargin: 0) - marker2 = editor.markBufferRange([[4, 0], [6, 0]], invalidate: 'touch') + marker2 = editor.markBufferRange([[4, 0], [6, 2]], invalidate: 'touch') decoration2 = editor.decorateMarker(marker2, type: 'line', class: 'b') expect(lineStateForScreenRow(presenter, 3).decorationClasses).toBeNull() @@ -300,7 +288,7 @@ describe "TextEditorPresenter", -> expect(lineStateForScreenRow(presenter, 6).decorationClasses).toEqual ['a', 'b'] expect(lineStateForScreenRow(presenter, 7).decorationClasses).toBeNull() - marker1.setBufferRange([[2, 0], [4, 0]]) + marker1.setBufferRange([[2, 0], [4, 2]]) expect(lineStateForScreenRow(presenter, 1).decorationClasses).toBeNull() expect(lineStateForScreenRow(presenter, 2).decorationClasses).toEqual ['a'] expect(lineStateForScreenRow(presenter, 3).decorationClasses).toEqual ['a'] @@ -352,3 +340,12 @@ describe "TextEditorPresenter", -> marker.clearTail() expect(lineStateForScreenRow(presenter, 6).decorationClasses).toBeNull() + + it "does not decorate the last line of a non-empty line decoration range if it ends at column 0", -> + presenter = new TextEditorPresenter(model: editor, clientHeight: 130, scrollTop: 0, lineHeight: 10, lineOverdrawMargin: 0) + marker = editor.markBufferRange([[4, 0], [6, 0]]) + decoration = editor.decorateMarker(marker, type: 'line', class: 'a') + + expect(lineStateForScreenRow(presenter, 4).decorationClasses).toEqual ['a'] + expect(lineStateForScreenRow(presenter, 5).decorationClasses).toEqual ['a'] + expect(lineStateForScreenRow(presenter, 6).decorationClasses).toBeNull() diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index 43ee62dc4..a2f018dd0 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -108,9 +108,11 @@ class TextEditorPresenter continue if properties.onlyNonEmpty else continue if properties.onlyEmpty + continue if row is range.end.row and range.end.column is 0 decorationClasses ?= [] decorationClasses.push(properties.class) + decorationClasses setScrollTop: (@scrollTop) ->