diff --git a/spec/extensions/command-interpreter-spec.coffee b/spec/extensions/command-interpreter-spec.coffee index 056ff4da6..e68795ebe 100644 --- a/spec/extensions/command-interpreter-spec.coffee +++ b/spec/extensions/command-interpreter-spec.coffee @@ -232,4 +232,16 @@ describe "CommandInterpreter", -> interpreter.eval(editor, 's/current/foo/g') expect(buffer.lineForRow(5)).toBe ' foo = items.shift();' - expect(buffer.lineForRow(6)).toBe ' foo < pivot ? left.push(foo) : right.push(current);' \ No newline at end of file + expect(buffer.lineForRow(6)).toBe ' foo < pivot ? left.push(foo) : right.push(current);' + + describe "when command selects folded text", -> + it "unfolds lines that command selects", -> + editor.createFold(1, 9) + editor.createFold(5, 8) + editor.setSelectedBufferRange([[0,0], [0,0]]) + + interpreter.eval(editor, '/push/') + expect(editor.getSelection().getBufferRange()).toEqual [[6,29], [6,33]] + expect(editor.lineForScreenRow(1).fold).toBeUndefined() + expect(editor.lineForScreenRow(5).fold).toBeUndefined() + expect(editor.lineForScreenRow(6).text).toBe buffer.lineForRow(6) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 3c2fc9923..2f37d7c8a 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -217,6 +217,7 @@ class Editor extends View softWrapColumn ?= @calcSoftWrapColumn() @activeEditSession.setSoftWrapColumn(softWrapColumn) if softWrapColumn + lineForScreenRow: (screenRow) -> @activeEditSession.lineForScreenRow(screenRow) linesForScreenRows: (start, end) -> @activeEditSession.linesForScreenRows(start, end) screenLineCount: -> @activeEditSession.screenLineCount() maxScreenLineLength: -> @activeEditSession.maxScreenLineLength() diff --git a/src/extensions/command-interpreter/composite-command.coffee b/src/extensions/command-interpreter/composite-command.coffee index 4df55e351..0dc9ceed2 100644 --- a/src/extensions/command-interpreter/composite-command.coffee +++ b/src/extensions/command-interpreter/composite-command.coffee @@ -10,6 +10,11 @@ class CompositeCommand currentRanges = editor.getSelectionsOrderedByBufferPosition().map (selection) -> selection.getBufferRange() for currentRange in currentRanges newRanges.push(command.execute(editor, currentRange)...) + + for range in newRanges + for row in [range.start.row..range.end.row] + editor.destroyFoldsContainingBufferRow(row) + editor.setSelectedBufferRanges(newRanges) reverse: ->