Merge pull request #164 from jazzpi/fix-mark-address
Fix mark addresses and add specs for addresses
This commit is contained in:
commit
f22ae13cfd
2 changed files with 63 additions and 2 deletions
|
|
@ -24,7 +24,7 @@ class Command
|
|||
mark = @vimState.marks[str[1]]
|
||||
unless mark?
|
||||
throw new CommandError("Mark #{str} not set.")
|
||||
addr = mark.bufferMarker.range.end.row
|
||||
addr = mark.getEndBufferPosition().row
|
||||
else if str[0] is "/"
|
||||
addr = Find.findNextInBuffer(@editor.buffer, curPos, str[1...-1])
|
||||
unless addr?
|
||||
|
|
|
|||
|
|
@ -65,6 +65,68 @@ describe "the commands", ->
|
|||
openEx = ->
|
||||
atom.commands.dispatch(editorElement, "ex-mode:open")
|
||||
|
||||
describe "as a motion", ->
|
||||
beforeEach ->
|
||||
editor.setCursorBufferPosition([0, 0])
|
||||
|
||||
it "moves the cursor to a specific line", ->
|
||||
openEx()
|
||||
submitNormalModeInputText '2'
|
||||
|
||||
expect(editor.getCursorBufferPosition()).toEqual [1, 0]
|
||||
|
||||
it "moves to the second address", ->
|
||||
openEx()
|
||||
submitNormalModeInputText '1,3'
|
||||
|
||||
expect(editor.getCursorBufferPosition()).toEqual [2, 0]
|
||||
|
||||
it "works with offsets", ->
|
||||
openEx()
|
||||
submitNormalModeInputText '2+1'
|
||||
expect(editor.getCursorBufferPosition()).toEqual [2, 0]
|
||||
|
||||
openEx()
|
||||
submitNormalModeInputText '-2'
|
||||
expect(editor.getCursorBufferPosition()).toEqual [0, 0]
|
||||
|
||||
it "doesn't move when the address is the current line", ->
|
||||
openEx()
|
||||
submitNormalModeInputText '.'
|
||||
expect(editor.getCursorBufferPosition()).toEqual [0, 0]
|
||||
|
||||
openEx()
|
||||
submitNormalModeInputText ','
|
||||
expect(editor.getCursorBufferPosition()).toEqual [0, 0]
|
||||
|
||||
it "moves to the last line", ->
|
||||
openEx()
|
||||
submitNormalModeInputText '$'
|
||||
expect(editor.getCursorBufferPosition()).toEqual [3, 0]
|
||||
|
||||
it "moves to a mark's line", ->
|
||||
keydown('l')
|
||||
keydown('m')
|
||||
normalModeInputKeydown 'a'
|
||||
keydown('j')
|
||||
openEx()
|
||||
submitNormalModeInputText "'a"
|
||||
expect(editor.getCursorBufferPosition()).toEqual [0, 0]
|
||||
|
||||
it "moves to a specified search", ->
|
||||
openEx()
|
||||
submitNormalModeInputText '/def'
|
||||
expect(editor.getCursorBufferPosition()).toEqual [1, 0]
|
||||
|
||||
openEx()
|
||||
submitNormalModeInputText '?abc'
|
||||
expect(editor.getCursorBufferPosition()).toEqual [0, 0]
|
||||
|
||||
editor.setCursorBufferPosition([3, 0])
|
||||
openEx()
|
||||
submitNormalModeInputText '/ef'
|
||||
expect(editor.getCursorBufferPosition()).toEqual [1, 0]
|
||||
|
||||
describe ":write", ->
|
||||
describe "when editing a new file", ->
|
||||
beforeEach ->
|
||||
|
|
@ -575,7 +637,6 @@ describe "the commands", ->
|
|||
waitsFor -> processedOpStack
|
||||
editor.setText('abc\ndef\nghi\njkl')
|
||||
editor.setCursorBufferPosition([1, 1])
|
||||
# For some reason, keydown(':') doesn't work here :/
|
||||
atom.commands.dispatch(editorElement, 'ex-mode:open')
|
||||
submitNormalModeInputText(',/k/delete')
|
||||
expect(editor.getText()).toEqual('abc\n')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue