diff --git a/spec/text-editor-presenter-spec.coffee b/spec/text-editor-presenter-spec.coffee index 090c9501c..98780df0e 100644 --- a/spec/text-editor-presenter-spec.coffee +++ b/spec/text-editor-presenter-spec.coffee @@ -409,6 +409,21 @@ describe "TextEditorPresenter", -> expectStateUpdate presenter, -> editor.setMini(true) expect(lineStateForScreenRow(presenter, 0).decorationClasses).toBeNull() + it "only applies decorations to screen rows that are spanned by their marker when lines are soft-wrapped", -> + editor.setText("a line that wraps, ok") + editor.setSoftWrapped(true) + editor.setEditorWidthInChars(16) + marker = editor.markBufferRange([[0, 0], [0, 2]]) + editor.decorateMarker(marker, type: 'line', class: 'a') + presenter = new TextEditorPresenter(model: editor, clientHeight: 10, scrollTop: 0, lineHeight: 10, lineOverdrawMargin: 0) + + expect(lineStateForScreenRow(presenter, 0).decorationClasses).toContain 'a' + expect(lineStateForScreenRow(presenter, 1).decorationClasses).toBeNull() + + marker.setBufferRange([[0, 0], [0, Infinity]]) + expect(lineStateForScreenRow(presenter, 0).decorationClasses).toContain 'a' + expect(lineStateForScreenRow(presenter, 1).decorationClasses).toContain 'a' + describe ".cursors", -> stateForCursor = (presenter, cursorIndex) -> presenter.state.content.cursors[presenter.model.getCursors()[cursorIndex].id] @@ -1065,6 +1080,21 @@ describe "TextEditorPresenter", -> expectStateUpdate presenter, -> editor.setMini(true) expect(lineNumberStateForScreenRow(presenter, 0).decorationClasses).toBeNull() + it "only applies decorations to screen rows that are spanned by their marker when lines are soft-wrapped", -> + editor.setText("a line that wraps, ok") + editor.setSoftWrapped(true) + editor.setEditorWidthInChars(16) + marker = editor.markBufferRange([[0, 0], [0, 2]]) + editor.decorateMarker(marker, type: 'line-number', class: 'a') + presenter = new TextEditorPresenter(model: editor, clientHeight: 10, scrollTop: 0, lineHeight: 10, lineOverdrawMargin: 0) + + expect(lineNumberStateForScreenRow(presenter, 0).decorationClasses).toContain 'a' + expect(lineNumberStateForScreenRow(presenter, 1).decorationClasses).toBeNull() + + marker.setBufferRange([[0, 0], [0, Infinity]]) + expect(lineNumberStateForScreenRow(presenter, 0).decorationClasses).toContain 'a' + expect(lineNumberStateForScreenRow(presenter, 1).decorationClasses).toContain 'a' + describe ".foldable", -> it "marks line numbers at the start of a foldable region as foldable", -> presenter = new TextEditorPresenter(model: editor, clientHeight: 130, scrollTop: 0, lineHeight: 10, lineOverdrawMargin: 0) diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index b130d395e..65e738241 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -251,6 +251,7 @@ class TextEditorPresenter properties = decoration.getProperties() range = decoration.getMarker().getScreenRange() + continue unless range.intersectsRow(row) if range.isEmpty() continue if properties.onlyNonEmpty else @@ -271,6 +272,7 @@ class TextEditorPresenter properties = decoration.getProperties() range = decoration.getMarker().getScreenRange() + continue unless range.intersectsRow(row) if range.isEmpty() continue if properties.onlyNonEmpty else