If command panel selects text within a fold, the fold is destroyed

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-06-14 14:00:35 -07:00
parent 8a2aa881f7
commit 9ada2daebd
3 changed files with 19 additions and 1 deletions

View File

@@ -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);'
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)

View File

@@ -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()

View File

@@ -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: ->