diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index 797d0b214..01b7885d6 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -2436,6 +2436,20 @@ describe "Editor", -> expect(editor.getCursorBufferPosition()).toEqual [3, 0] + describe "when a 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' + + editor.setCursorBufferPosition([3,0]) + editor.trigger 'unfold' + + expect(editor.find('.fold')).not.toExist() + expect(editor.visibleLines.find('.line:eq(4)').text()).toMatch /4-+/ + expect(editor.visibleLines.find('.line:eq(5)').text()).toMatch /5/ + + expect(editor.getCursorBufferPosition()).toEqual [3, 0] + describe "editor-path-change event", -> it "emits event when buffer's path is changed", -> editor = new Editor diff --git a/src/app/editor.coffee b/src/app/editor.coffee index fbcb0cab9..8031abdc2 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -119,6 +119,7 @@ class Editor extends View 'redo': @redo 'toggle-soft-wrap': @toggleSoftWrap 'fold-selection': @foldSelection + 'unfold': => @unfoldRow(@getCursorBufferPosition().row) 'split-left': @splitLeft 'split-right': @splitRight 'split-up': @splitUp @@ -681,6 +682,9 @@ class Editor extends View foldSelection: -> @getSelection().fold() + unfoldRow: (row) -> + @renderer.largestFoldForBufferRow(row)?.destroy() + undo: -> if ranges = @buffer.undo() @setSelectedBufferRanges(ranges) diff --git a/src/app/keymaps/editor.coffee b/src/app/keymaps/editor.coffee index 37d2e9a8f..fe392b3dd 100644 --- a/src/app/keymaps/editor.coffee +++ b/src/app/keymaps/editor.coffee @@ -28,6 +28,7 @@ window.keymap.bindKeys '.editor', 'meta-Z': 'redo' 'alt-meta-w': 'toggle-soft-wrap' 'alt-meta-f': 'fold-selection' + 'alt-meta-u': 'unfold' 'alt-meta-left': 'split-left' 'alt-meta-right': 'split-right' 'alt-meta-up': 'split-up'