1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
helpers = require './spec-helper'
describe "Prefixes", ->
[editor, editorElement, vimState] = []
beforeEach ->
vimMode = atom.packages.loadPackage('vim-mode')
vimMode.activateResources()
helpers.getEditorElement (element) ->
editorElement = element
editor = editorElement.getModel()
vimState = editorElement.vimState
vimState.activateCommandMode()
vimState.resetCommandMode()
keydown = (key, options={}) ->
options.element ?= editorElement
helpers.keydown(key, options)
describe "Repeat", ->
describe "with operations", ->
beforeEach ->
editor.setText("123456789abc")
editor.setCursorScreenPosition([0, 0])
it "repeats N times", ->
keydown('3')
keydown('x')
expect(editor.getText()).toBe '456789abc'
it "repeats NN times", ->
keydown('1')
keydown('0')
keydown('x')
expect(editor.getText()).toBe 'bc'
describe "with motions", ->
beforeEach ->
editor.setText('one two three')
editor.setCursorScreenPosition([0, 0])
it "repeats N times", ->
keydown('d')
keydown('2')
keydown('w')
expect(editor.getText()).toBe 'three'
describe "in visual mode", ->
beforeEach ->
editor.setText('one two three')
editor.setCursorScreenPosition([0, 0])
it "repeats movements in visual mode", ->
keydown("v")
keydown("2")
keydown("w")
expect(editor.getCursorScreenPosition()).toEqual [0, 9]
describe "Register", ->
describe "the a register", ->
it "saves a value for future reading", ->
vimState.setRegister('a', text: 'new content')
expect(vimState.getRegister("a").text).toEqual 'new content'
it "overwrites a value previously in the register", ->
vimState.setRegister('a', text: 'content')
vimState.setRegister('a', text: 'new content')
expect(vimState.getRegister("a").text).toEqual 'new content'
describe "the B register", ->
it "saves a value for future reading", ->
vimState.setRegister('B', text: 'new content')
expect(vimState.getRegister("b").text).toEqual 'new content'
expect(vimState.getRegister("B").text).toEqual 'new content'
it "appends to a value previously in the register", ->
vimState.setRegister('b', text: 'content')
vimState.setRegister('B', text: 'new content')
expect(vimState.getRegister("b").text).toEqual 'contentnew content'
it "appends linewise to a linewise value previously in the register", ->
vimState.setRegister('b', {type: 'linewise', text: 'content\n'})
vimState.setRegister('B', text: 'new content')
expect(vimState.getRegister("b").text).toEqual 'content\nnew content\n'
it "appends linewise to a character value previously in the register", ->
vimState.setRegister('b', text: 'content')
vimState.setRegister('B', {type: 'linewise', text: 'new content\n'})
expect(vimState.getRegister("b").text).toEqual 'content\nnew content\n'
describe "the * register", ->
describe "reading", ->
it "is the same the system clipboard", ->
expect(vimState.getRegister('*').text).toEqual 'initial clipboard content'
expect(vimState.getRegister('*').type).toEqual 'character'
describe "writing", ->
beforeEach ->
vimState.setRegister('*', text: 'new content')
it "overwrites the contents of the system clipboard", ->
expect(atom.clipboard.read()).toEqual 'new content'
# FIXME: once linux support comes out, this needs to read from
# the correct clipboard. For now it behaves just like the * register
# See :help x11-cut-buffer and :help registers for more details on how these
# registers work on an X11 based system.
describe "the + register", ->
describe "reading", ->
it "is the same the system clipboard", ->
expect(vimState.getRegister('*').text).toEqual 'initial clipboard content'
expect(vimState.getRegister('*').type).toEqual 'character'
describe "writing", ->
beforeEach ->
vimState.setRegister('*', text: 'new content')
it "overwrites the contents of the system clipboard", ->
expect(atom.clipboard.read()).toEqual 'new content'
describe "the _ register", ->
describe "reading", ->
it "is always the empty string", ->
expect(vimState.getRegister("_").text).toEqual ''
describe "writing", ->
it "throws away anything written to it", ->
vimState.setRegister('_', text: 'new content')
expect(vimState.getRegister("_").text).toEqual ''
describe "the % register", ->
beforeEach ->
spyOn(editor, 'getURI').andReturn('/Users/atom/known_value.txt')
describe "reading", ->
it "returns the filename of the current editor", ->
expect(vimState.getRegister('%').text).toEqual '/Users/atom/known_value.txt'
describe "writing", ->
it "throws away anything written to it", ->
vimState.setRegister('%', "new content")
expect(vimState.getRegister('%').text).toEqual '/Users/atom/known_value.txt'
|