Merge branch 'master' into snippets

This commit is contained in:
Nathan Sobo 2012-06-22 16:25:33 -06:00
commit 6389b19b7c
2 changed files with 16 additions and 7 deletions

View File

@ -740,6 +740,13 @@ describe "EditSession", ->
describe ".backspace()", ->
describe "when there is a single cursor", ->
changeScreenRangeHandler = null
beforeEach ->
selection = editSession.getLastSelection()
changeScreenRangeHandler = jasmine.createSpy('changeScreenRangeHandler')
selection.on 'change-screen-range', changeScreenRangeHandler
describe "when the cursor is on the middle of the line", ->
it "removes the character before the cursor", ->
editSession.setCursorScreenPosition(row: 1, column: 7)
@ -750,6 +757,7 @@ describe "EditSession", ->
line = buffer.lineForRow(1)
expect(line).toBe " var ort = function(items) {"
expect(editSession.getCursorScreenPosition()).toEqual {row: 1, column: 6}
expect(changeScreenRangeHandler).toHaveBeenCalled()
describe "when the cursor is at the beginning of a line", ->
it "joins it with the line above", ->
@ -764,9 +772,10 @@ describe "EditSession", ->
line1 = buffer.lineForRow(1)
expect(line0).toBe "var quicksort = function () { var sort = function(items) {"
expect(line1).toBe " if (items.length <= 1) return items;"
expect(editSession.getCursorScreenPosition()).toEqual [0, originalLine0.length]
expect(changeScreenRangeHandler).toHaveBeenCalled()
describe "when the cursor is at the first column of the first line", ->
it "does nothing, but doesn't raise an error", ->
editSession.setCursorScreenPosition(row: 0, column: 0)

View File

@ -164,10 +164,9 @@ class Selection
includeNewline = bufferRange.start.column == 0 or bufferRange.start.row >= fold.startRow
bufferRange = bufferRange.union(fold.getBufferRange({ includeNewline }))
@editSession.buffer.delete(bufferRange) unless bufferRange.isEmpty()
if @cursor
@cursor.setBufferPosition(bufferRange.start)
@clear()
@modifyScreenRange =>
@editSession.buffer.delete(bufferRange) unless bufferRange.isEmpty()
@cursor?.setBufferPosition(bufferRange.start)
indentSelectedRows: ->
range = @getBufferRange()
@ -222,8 +221,9 @@ class Selection
modifyScreenRange: (fn) ->
oldScreenRange = @getScreenRange()
fn()
newScreenRange = @getScreenRange()
@trigger 'change-screen-range', newScreenRange unless oldScreenRange.isEqual(newScreenRange)
if @cursor
newScreenRange = @getScreenRange()
@trigger 'change-screen-range', newScreenRange unless oldScreenRange.isEqual(newScreenRange)
placeAnchor: ->
@anchor = @editSession.addAnchor()