diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index dcb5a17ca..9c512ae52 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -2446,7 +2446,7 @@ describe "Editor", -> expect(editor.getCursorBufferPosition()).toEqual [3, 0] - describe "when a cursor is on a fold placeholder line", -> + describe "when the unfold event is triggered when the cursor is on a fold placeholder line", -> it "removes the associated fold and places the cursor at its beginning", -> editor.getSelection().setBufferRange(new Range([3, 0], [9, 0])) editor.trigger 'fold-selection' @@ -2461,7 +2461,7 @@ describe "Editor", -> expect(editor.getCursorBufferPosition()).toEqual [3, 0] describe "when a selection starts/stops intersecting a fold", -> - it "adds/removes the 'selected' class to the fold's line element", -> + it "adds/removes the 'selected' class to the fold's line element and hides the cursor if it is on the fold line", -> editor.createFold(2, 4) editor.setSelectionBufferRange([[1, 0], [2, 0]], reverse: true) @@ -2478,6 +2478,10 @@ describe "Editor", -> editor.setCursorScreenPosition([2,0]) expect(editor.lineElementForScreenRow(2)).toMatchSelector('.fold.selected') + expect(editor.find('.cursor').css('display')).toBe 'none' + + editor.setCursorScreenPosition([3,0]) + expect(editor.find('.cursor').css('display')).toBe 'block' describe "when a selected fold is scrolled into view (and the fold line was not previously rendered)", -> it "renders the fold's line element with the 'selected' class", -> diff --git a/src/app/cursor.coffee b/src/app/cursor.coffee index 6bfcef620..a3fc37abd 100644 --- a/src/app/cursor.coffee +++ b/src/app/cursor.coffee @@ -177,4 +177,9 @@ class Cursor extends View if this == _.last(@editor.getCursors()) @editor.scrollTo(pixelPosition) + if @editor.isFoldedAtScreenRow(screenPosition.row) + @hide() + else + @show() + @selection.updateAppearance() diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 2cecb9487..044478a2b 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -343,7 +343,6 @@ class Editor extends View screenRow = @firstRenderedScreenRow + i element = @lineElementForScreenRow(screenRow) if @compositeSelection.intersectsBufferRange(fold.getBufferRange()) - element.addClass('selected') else element.removeClass('selected') @@ -363,6 +362,9 @@ class Editor extends View getLastScreenRow: -> @screenLineCount() - 1 + isFoldedAtScreenRow: (screenRow) -> + @screenLineForRow(screenRow).fold? + destroyFoldsContainingBufferRow: (bufferRow) -> @renderer.destroyFoldsContainingBufferRow(bufferRow)