mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Rename un/foldScopeContainingBufferRow to un/foldBufferRow.
Scope containing buffer row was a misnomer. Waiting until I implement the repeat folding feature before considering a better name.
This commit is contained in:
@@ -172,41 +172,41 @@ describe "DisplayBuffer", ->
|
||||
expect(displayBuffer.activeFolds[4].length).toBe(1)
|
||||
|
||||
it "doesn't fold lines that are already folded", ->
|
||||
displayBuffer.foldScopeContainingBufferRow(4)
|
||||
displayBuffer.foldBufferRow(4)
|
||||
displayBuffer.foldAll()
|
||||
expect(Object.keys(displayBuffer.activeFolds).length).toBe(3)
|
||||
expect(displayBuffer.activeFolds[0].length).toBe(1)
|
||||
expect(displayBuffer.activeFolds[1].length).toBe(1)
|
||||
expect(displayBuffer.activeFolds[4].length).toBe(1)
|
||||
|
||||
describe ".foldScopeContainingBufferRow(bufferRow)", ->
|
||||
describe ".foldBufferRow(bufferRow)", ->
|
||||
describe "when bufferRow can be folded", ->
|
||||
it "creates a fold based on the syntactic region starting at the given row", ->
|
||||
displayBuffer.foldScopeContainingBufferRow(1)
|
||||
displayBuffer.foldBufferRow(1)
|
||||
fold = displayBuffer.lineForRow(1).fold
|
||||
expect(fold.startRow).toBe 1
|
||||
expect(fold.endRow).toBe 9
|
||||
|
||||
describe "when bufferRow can't be folded", ->
|
||||
it "searches upward for the first row that begins a syntatic region containing the given buffer row (and folds it)", ->
|
||||
displayBuffer.foldScopeContainingBufferRow(8)
|
||||
displayBuffer.foldBufferRow(8)
|
||||
fold = displayBuffer.lineForRow(1).fold
|
||||
expect(fold.startRow).toBe 1
|
||||
expect(fold.endRow).toBe 9
|
||||
|
||||
describe ".unfoldScopeContainingBufferRow(bufferRow)", ->
|
||||
describe ".unfoldBufferRow(bufferRow)", ->
|
||||
describe "when bufferRow can be unfolded", ->
|
||||
it "destroys a fold based on the syntactic region starting at the given row", ->
|
||||
displayBuffer.foldScopeContainingBufferRow(1)
|
||||
displayBuffer.foldBufferRow(1)
|
||||
expect(displayBuffer.lineForRow(1).fold).toBeDefined()
|
||||
|
||||
displayBuffer.unfoldScopeContainingBufferRow(1)
|
||||
displayBuffer.unfoldBufferRow(1)
|
||||
expect(displayBuffer.lineForRow(1).fold).toBeUndefined()
|
||||
|
||||
describe "when bufferRow can't be unfolded", ->
|
||||
it "does not throw an error", ->
|
||||
expect(displayBuffer.lineForRow(1).fold).toBeUndefined()
|
||||
displayBuffer.unfoldScopeContainingBufferRow(1)
|
||||
displayBuffer.unfoldBufferRow(1)
|
||||
expect(displayBuffer.lineForRow(1).fold).toBeUndefined()
|
||||
|
||||
describe "primitive folding", ->
|
||||
|
||||
@@ -912,7 +912,7 @@ describe "EditSession", ->
|
||||
describe "when the selection ends on a folded line", ->
|
||||
it "destroys the fold", ->
|
||||
editSession.setSelectedBufferRange([[3,0], [4,0]])
|
||||
editSession.foldScopeContainingBufferRow(4)
|
||||
editSession.foldBufferRow(4)
|
||||
editSession.backspace()
|
||||
|
||||
expect(buffer.lineForRow(3)).toBe " return sort(left).concat(pivot).concat(sort(right));"
|
||||
@@ -972,7 +972,7 @@ describe "EditSession", ->
|
||||
|
||||
describe "when the cursor is on the end of a line above a fold", ->
|
||||
it "only deletes the lines inside the fold", ->
|
||||
editSession.foldScopeContainingBufferRow(4)
|
||||
editSession.foldBufferRow(4)
|
||||
editSession.setCursorScreenPosition([3, Infinity])
|
||||
cursorPositionBefore = editSession.getCursorScreenPosition()
|
||||
|
||||
@@ -984,7 +984,7 @@ describe "EditSession", ->
|
||||
|
||||
describe "when the cursor is in the middle a line above a fold", ->
|
||||
it "deletes as normal", ->
|
||||
editSession.foldScopeContainingBufferRow(4)
|
||||
editSession.foldBufferRow(4)
|
||||
editSession.setCursorScreenPosition([3, 4])
|
||||
cursorPositionBefore = editSession.getCursorScreenPosition()
|
||||
|
||||
|
||||
@@ -1377,8 +1377,8 @@ describe "Editor", ->
|
||||
it "renders lines properly", ->
|
||||
editor.lineOverdraw = 1
|
||||
editor.attachToDom(heightInLines: 5)
|
||||
editor.activeEditSession.foldScopeContainingBufferRow(4)
|
||||
editor.activeEditSession.foldScopeContainingBufferRow(0)
|
||||
editor.activeEditSession.foldBufferRow(4)
|
||||
editor.activeEditSession.foldBufferRow(0)
|
||||
|
||||
expect(editor.renderedLines.find('.line').length).toBe 1
|
||||
expect(editor.renderedLines.find('.line').text()).toBe buffer.lineForRow(0)
|
||||
|
||||
@@ -56,7 +56,7 @@ class DisplayBuffer
|
||||
|
||||
@createFold(startRow, endRow)
|
||||
|
||||
foldScopeContainingBufferRow: (bufferRow) ->
|
||||
foldBufferRow: (bufferRow) ->
|
||||
for currentRow in [bufferRow..0]
|
||||
[startRow, endRow] = @tokenizedBuffer.rowRangeForFoldAtBufferRow(currentRow) ? []
|
||||
continue unless startRow? and startRow <= bufferRow <= endRow
|
||||
@@ -65,7 +65,7 @@ class DisplayBuffer
|
||||
|
||||
return
|
||||
|
||||
unfoldScopeContainingBufferRow: (bufferRow) ->
|
||||
unfoldBufferRow: (bufferRow) ->
|
||||
for currentRow in [bufferRow..0]
|
||||
[startRow, endRow] = @tokenizedBuffer.rowRangeForFoldAtBufferRow(currentRow) ? []
|
||||
continue unless startRow? and startRow <= bufferRow <= endRow
|
||||
|
||||
@@ -200,17 +200,17 @@ class EditSession
|
||||
|
||||
foldCurrentRow: ->
|
||||
bufferRow = @bufferPositionForScreenPosition(@getCursorScreenPosition()).row
|
||||
@foldScopeContainingBufferRow(bufferRow)
|
||||
@foldBufferRow(bufferRow)
|
||||
|
||||
foldScopeContainingBufferRow: (bufferRow) ->
|
||||
@displayBuffer.foldScopeContainingBufferRow(bufferRow)
|
||||
foldBufferRow: (bufferRow) ->
|
||||
@displayBuffer.foldBufferRow(bufferRow)
|
||||
|
||||
unfoldCurrentRow: ->
|
||||
bufferRow = @bufferPositionForScreenPosition(@getCursorScreenPosition()).row
|
||||
@unfoldScopeContainingBufferRow(bufferRow)
|
||||
@unfoldBufferRow(bufferRow)
|
||||
|
||||
unfoldScopeContainingBufferRow: (bufferRow) ->
|
||||
@displayBuffer.unfoldScopeContainingBufferRow(bufferRow)
|
||||
unfoldBufferRow: (bufferRow) ->
|
||||
@displayBuffer.unfoldBufferRow(bufferRow)
|
||||
|
||||
foldSelection: ->
|
||||
selection.fold() for selection in @getSelections()
|
||||
|
||||
Reference in New Issue
Block a user