Cover other next word cases.

Now it moves to words on the next line and also to the next empty line.
This commit is contained in:
Nathan Sobo
2012-01-13 19:47:09 -08:00
parent 1809ba4ef1
commit d94d387101
3 changed files with 25 additions and 6 deletions

View File

@@ -61,8 +61,8 @@ class Editor extends Template
getCursor: ->
@getAceSession().getSelection().getCursor()
getLineText: ->
@buffer.getLine(@getRow())
getLineText: (row) ->
@buffer.getLine(row)
getRow: ->
{ row } = @getCursor()

View File

@@ -54,12 +54,17 @@ module.exports =
execute: (editor) ->
regex = getWordRegex()
{ row, column } = editor.getCursor()
rightOfCursor = editor.getLineText().substring(column)
rightOfCursor = editor.getLineText(row).substring(column)
match = regex.exec(rightOfCursor)
# If we're on top of part of a word, match the next one.
match = regex.exec(rightOfCursor) if match?.index is 0
column += match.index
if match
column += match.index
else
nextLineMatch = regex.exec(editor.getLineText(++row))
column = nextLineMatch?.index or 0
editor.setCursor { row, column }