Merge branch 'master' of github.com:github/atom

This commit is contained in:
Nathan Sobo
2012-02-07 12:10:34 -07:00
4 changed files with 30 additions and 2 deletions

View File

@@ -138,6 +138,27 @@ describe "VimMode", ->
expect(editor.buffer.getText()).toBe "four"
expect(editor.getCursorPosition()).toEqual([0,0])
describe "when followed by a b", ->
it "deletes to the beginning of the previous word", ->
editor.buffer.setText("abcd efg")
editor.setCursorPosition([0,2])
editor.trigger keydownEvent('d')
editor.trigger keydownEvent('b')
expect(editor.buffer.getText()).toBe "cd efg"
expect(editor.getCursorPosition()).toEqual([0,0])
# editor.buffer.setText("one two three four")
# editor.setCursorPosition([0,11])
# editor.trigger keydownEvent('d')
# editor.trigger keydownEvent('3')
# editor.trigger keydownEvent('b')
# expect(editor.buffer.getText()).toBe "ee four"
# expect(editor.getCursorPosition()).toEqual([0,0])
describe "basic motion bindings", ->
beforeEach ->
editor.buffer.setText("12345\nabcde\nABCDE")

View File

@@ -88,7 +88,7 @@ class Cursor extends View
@setPosition({row, column})
moveLeftWhile: (regex) ->
moveLeftUntilMatch: (regex) ->
row = @getRow()
column = @getColumn()
offset = 0

View File

@@ -132,6 +132,10 @@ class Selection extends View
@modifySelection =>
@cursor.moveDown()
selectLeftUntilMatch: (regex) ->
@modifySelection =>
@cursor.moveLeftUntilMatch(regex)
selectToPosition: (position) ->
@modifySelection =>
@cursor.setPosition(position)

View File

@@ -31,7 +31,10 @@ class MoveDown extends Motion
class MoveToPreviousWord extends Motion
execute: ->
@editor.cursor.moveLeftWhile /^\s*(\w+|[^A-Za-z0-9_ ]+)/g
@editor.getCursor().moveLeftUntilMatch /^\s*(\w+|[^A-Za-z0-9_ ]+)/
select: ->
@editor.getSelection().selectLeftUntilMatch /^\s*(\w+|[^A-Za-z0-9_ ]+)/
class MoveToNextWord extends Motion
execute: ->