diff --git a/lib/command.coffee b/lib/command.coffee index 9097c6c..ffb9b28 100644 --- a/lib/command.coffee +++ b/lib/command.coffee @@ -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? diff --git a/spec/ex-commands-spec.coffee b/spec/ex-commands-spec.coffee index 72775f8..311f18b 100644 --- a/spec/ex-commands-spec.coffee +++ b/spec/ex-commands-spec.coffee @@ -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')