@@ -114,34 +114,39 @@ describe "VimState", ->
114114 expect (editor .getLastSelection ().getText ()).toEqual ' 012345\n '
115115
116116 describe " the ctrl-v keybinding" , ->
117- beforeEach -> keydown (' v' , ctrl : true )
117+ beforeEach ->
118+ editor .setText (" 012345\n abcdef" )
119+ editor .setCursorScreenPosition ([0 , 0 ])
120+ keydown (' v' , ctrl : true )
118121
119- it " puts the editor into visual characterwise mode" , ->
122+ it " puts the editor into visual blockwise mode" , ->
120123 expect (editorElement .classList .contains (' visual-mode' )).toBe (true )
121124 expect (vimState .submode ).toEqual ' blockwise'
122125 expect (editorElement .classList .contains (' normal-mode' )).toBe (false )
123126
124127 describe " selecting text" , ->
125128 beforeEach ->
126- spyOn (_ ._ , " now" ).andCallFake -> window .now
127129 editor .setText (" abc def" )
130+ editor .setCursorScreenPosition ([0 , 0 ])
128131
129132 it " puts the editor into visual mode" , ->
130133 expect (vimState .mode ).toEqual ' normal'
131- editor .setSelectedBufferRanges ([[[0 , 0 ], [0 , 3 ]]])
132-
133- advanceClock (100 )
134+ atom .commands .dispatch (editorElement, " core:select-right" )
134135
135136 expect (vimState .mode ).toEqual ' visual'
136137 expect (vimState .submode ).toEqual ' characterwise'
137- expect (editor .getSelectedBufferRanges ()).toEqual ([[[0 , 0 ], [0 , 3 ]]])
138+ expect (editor .getSelectedBufferRanges ()).toEqual ([[[0 , 0 ], [0 , 1 ]]])
138139
139140 it " handles the editor being destroyed shortly after selecting text" , ->
140141 editor .setSelectedBufferRanges ([[[0 , 0 ], [0 , 3 ]]])
141142 editor .destroy ()
142143 vimState .destroy ()
143144 advanceClock (100 )
144145
146+ it " handles native selection such as core:select-all" , ->
147+ atom .commands .dispatch (editorElement, " core:select-all" )
148+ expect (editor .getSelectedBufferRanges ()).toEqual ([[[0 , 0 ], [0 , 7 ]]])
149+
145150 describe " the i keybinding" , ->
146151 beforeEach -> keydown (' i' )
147152
@@ -158,18 +163,21 @@ describe "VimState", ->
158163 expect (editorElement .classList .contains (' normal-mode' )).toBe (false )
159164
160165 describe " with content" , ->
161- beforeEach -> editor .setText (" 012345\n\n abcdef" )
166+ beforeEach ->
167+ editor .setText (" 012345\n\n abcdef" )
168+ editor .setCursorScreenPosition ([0 , 0 ])
162169
163170 describe " on a line with content" , ->
164- beforeEach -> editor .setCursorScreenPosition ([0 , 6 ])
165-
166- it " does not allow the cursor to be placed on the \n character" , ->
171+ it " does not allow atom commands to place the cursor on the \\ n character" , ->
172+ atom .commands .dispatch (editorElement, " editor:move-to-end-of-line" )
167173 expect (editor .getCursorScreenPosition ()).toEqual [0 , 5 ]
168174
169175 describe " on an empty line" , ->
170- beforeEach -> editor .setCursorScreenPosition ([1 , 0 ])
176+ beforeEach ->
177+ editor .setCursorScreenPosition ([1 , 0 ])
178+ atom .commands .dispatch (editorElement, " editor:move-to-end-of-line" )
171179
172- it " allows the cursor to be placed on the \n character" , ->
180+ it " allows the cursor to be placed on the \\ n character" , ->
173181 expect (editor .getCursorScreenPosition ()).toEqual [1 , 0 ]
174182
175183 describe ' with character-input operations' , ->
@@ -206,9 +214,11 @@ describe "VimState", ->
206214 expect (editor .getCursorScreenPosition ()).toEqual [1 , 0 ]
207215
208216 describe " on a line with content" , ->
209- beforeEach -> editor .setCursorScreenPosition ([0 , 6 ])
217+ beforeEach ->
218+ editor .setCursorScreenPosition ([0 , 0 ])
219+ atom .commands .dispatch (editorElement, " editor:move-to-end-of-line" )
210220
211- it " allows the cursor to be placed on the \n character" , ->
221+ it " allows the cursor to be placed on the \\ n character" , ->
212222 expect (editor .getCursorScreenPosition ()).toEqual [0 , 6 ]
213223
214224 it " puts the editor into normal mode when <escape> is pressed" , ->
@@ -252,9 +262,10 @@ describe "VimState", ->
252262 describe " on a line with content" , ->
253263 beforeEach ->
254264 keydown (' R' , shift : true )
255- editor .setCursorScreenPosition ([0 , 6 ])
265+ editor .setCursorScreenPosition ([0 , 0 ])
266+ atom .commands .dispatch (editorElement, " editor:move-to-end-of-line" )
256267
257- it " allows the cursor to be placed on the \n character" , ->
268+ it " allows the cursor to be placed on the \\ n character" , ->
258269 expect (editor .getCursorScreenPosition ()).toEqual [0 , 6 ]
259270
260271 it " puts the editor into normal mode when <escape> is pressed" , ->
@@ -365,15 +376,13 @@ describe "VimState", ->
365376 ])
366377
367378 it " harmonizes selection directions" , ->
368- editor .setCursorBufferPosition ([0 , 0 ])
369- keydown (" e" )
370379 keydown (" e" )
371380 editor .addCursorAtBufferPosition ([0 , Infinity ])
372381 keydown (" h" )
373382 keydown (" h" )
374383
375384 expect (editor .getSelectedBufferRanges ()).toEqual ([
376- [[0 , 0 ], [0 , 5 ]],
385+ [[0 , 4 ], [0 , 5 ]],
377386 [[0 , 11 ], [0 , 13 ]]
378387 ])
379388 expect (editor .getCursorBufferPositions ()).toEqual ([
@@ -384,7 +393,7 @@ describe "VimState", ->
384393 keydown (" o" )
385394
386395 expect (editor .getSelectedBufferRanges ()).toEqual ([
387- [[0 , 0 ], [0 , 5 ]],
396+ [[0 , 4 ], [0 , 5 ]],
388397 [[0 , 11 ], [0 , 13 ]]
389398 ])
390399 expect (editor .getCursorBufferPositions ()).toEqual ([
0 commit comments