From c13346a455043f317b5a85e77543419f168ed9fd Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 16 May 2016 11:23:54 +0200 Subject: [PATCH] Show folded marker in the first screen row of a soft-wrapped buffer row --- spec/text-editor-presenter-spec.coffee | 29 +++++++++++++++++++------- src/text-editor-presenter.coffee | 4 +--- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/spec/text-editor-presenter-spec.coffee b/spec/text-editor-presenter-spec.coffee index 8cdc4e61a..af0260b95 100644 --- a/spec/text-editor-presenter-spec.coffee +++ b/spec/text-editor-presenter-spec.coffee @@ -3069,15 +3069,28 @@ describe "TextEditorPresenter", -> expect(lineNumberStateForScreenRow(presenter, 0).decorationClasses).toContain 'a' expect(lineNumberStateForScreenRow(presenter, 1).decorationClasses).toContain 'a' - it "applies the 'folded' decoration only to the initial screen row of a soft-wrapped buffer row", -> - editor.setSoftWrapped(true) - editor.setDefaultCharWidth(1) - editor.setEditorWidthInChars(15) - editor.foldBufferRange([[0, 20], [0, 22]]) - presenter = buildPresenter(explicitHeight: 35, scrollTop: 0, tileSize: 2) + describe "when a fold spans a single soft-wrapped buffer row", -> + it "applies the 'folded' decoration only to its initial screen row", -> + editor.setSoftWrapped(true) + editor.setDefaultCharWidth(1) + editor.setEditorWidthInChars(20) + editor.foldBufferRange([[0, 20], [0, 22]]) + editor.foldBufferRange([[0, 10], [0, 14]]) + presenter = buildPresenter(explicitHeight: 35, scrollTop: 0, tileSize: 2) - expect(lineNumberStateForScreenRow(presenter, 0).decorationClasses).toContain 'folded' - expect(lineNumberStateForScreenRow(presenter, 1).decorationClasses).toBeNull() + expect(lineNumberStateForScreenRow(presenter, 0).decorationClasses).toContain('folded') + expect(lineNumberStateForScreenRow(presenter, 1).decorationClasses).toBeNull() + + describe "when a fold is at the end of a soft-wrapped buffer row", -> + it "applies the 'folded' decoration only to its initial screen row", -> + editor.setSoftWrapped(true) + editor.setDefaultCharWidth(1) + editor.setEditorWidthInChars(25) + editor.foldBufferRow(1) + presenter = buildPresenter(explicitHeight: 35, scrollTop: 0, tileSize: 2) + + expect(lineNumberStateForScreenRow(presenter, 2).decorationClasses).toContain('folded') + expect(lineNumberStateForScreenRow(presenter, 3).decorationClasses).toBeNull() describe ".foldable", -> it "marks line numbers at the start of a foldable region as foldable", -> diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index 01a0293f6..1a7723128 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -1153,13 +1153,11 @@ class TextEditorPresenter if rangeIsReversed headScreenPosition = screenRange.start - headBufferPosition = bufferRange.start else headScreenPosition = screenRange.end - headBufferPosition = bufferRange.end if properties.class is 'folded' and Decoration.isType(properties, 'line-number') - screenRow = @model.screenRowForBufferRow(headBufferPosition.row) + screenRow = @model.screenRowForBufferRow(bufferRange.start.row) @lineNumberDecorationsByScreenRow[screenRow] ?= {} @lineNumberDecorationsByScreenRow[screenRow][decorationId] = properties else