@@ -190,10 +190,9 @@ describe "TextObjects", ->
190190 describe " the 'ip' text object" , ->
191191 beforeEach ->
192192 editor .setText (" \n Paragraph-1\n Paragraph-1\n Paragraph-1\n\n " )
193- editor .setCursorScreenPosition ([2 , 2 ])
193+ editor .setCursorBufferPosition ([2 , 2 ])
194194
195195 it " applies operators inside the current paragraph in operator-pending mode" , ->
196-
197196 keydown (' y' )
198197 keydown (' i' )
199198 keydown (' p' )
@@ -211,20 +210,39 @@ describe "TextObjects", ->
211210
212211 expect (editor .getSelectedScreenRange ()).toEqual [[1 , 0 ], [4 , 0 ]]
213212
213+ it " selects between paragraphs in visual mode if invoked on a empty line" , ->
214+ editor .setText (" text\n\n\n\n text\n " )
215+ editor .setCursorBufferPosition ([1 , 0 ])
216+
217+ keydown (' v' )
218+ keydown (' i' )
219+ keydown (' p' )
220+
221+ expect (editor .getSelectedScreenRange ()).toEqual [[1 , 0 ], [4 , 0 ]]
222+
223+ it " selects all the lines" , ->
224+ editor .setText (" text\n text\n text\n " )
225+ editor .setCursorBufferPosition ([0 , 0 ])
226+
227+ keydown (' v' )
228+ keydown (' i' )
229+ keydown (' p' )
230+
231+ expect (editor .getSelectedScreenRange ()).toEqual [[0 , 0 ], [3 , 0 ]]
232+
214233 describe " the 'ap' text object" , ->
215234 beforeEach ->
216- editor .setText (" text\n\n Paragraph-1\n Paragraph-1\n Paragraph-1\n\n moretext" )
235+ editor .setText (" text\n\n Paragraph-1\n Paragraph-1\n Paragraph-1\n\n\ n moretext" )
217236 editor .setCursorScreenPosition ([3 , 2 ])
218237
219238 it " applies operators around the current paragraph in operator-pending mode" , ->
220-
221239 keydown (' y' )
222240 keydown (' a' )
223241 keydown (' p' )
224242
225- expect (editor .getText ()).toBe " text\n\n Paragraph-1\n Paragraph-1\n Paragraph-1\n\n moretext"
243+ expect (editor .getText ()).toBe " text\n\n Paragraph-1\n Paragraph-1\n Paragraph-1\n\n\ n moretext"
226244 expect (editor .getCursorScreenPosition ()).toEqual [2 , 0 ]
227- expect (vimState .getRegister (' "' ).text ).toBe " Paragraph-1\n Paragraph-1\n Paragraph-1\n\n "
245+ expect (vimState .getRegister (' "' ).text ).toBe " Paragraph-1\n Paragraph-1\n Paragraph-1\n\n\n "
228246 expect (editorElement .classList .contains (' operator-pending-mode' )).toBe (false )
229247 expect (editorElement .classList .contains (' normal-mode' )).toBe (true )
230248
@@ -233,7 +251,31 @@ describe "TextObjects", ->
233251 keydown (' a' )
234252 keydown (' p' )
235253
236- expect (editor .getSelectedScreenRange ()).toEqual [[2 , 0 ], [6 , 0 ]]
254+ expect (editor .getSelectedScreenRange ()).toEqual [[2 , 0 ], [7 , 0 ]]
255+
256+ it " applies operators around the next paragraph in operator-pending mode when started from a blank/only-whitespace line" , ->
257+ editor .setText (" text\n\n\n\n Paragraph-1\n Paragraph-1\n Paragraph-1\n\n\n moretext" )
258+ editor .setCursorBufferPosition ([1 , 0 ])
259+
260+ keydown (' y' )
261+ keydown (' a' )
262+ keydown (' p' )
263+
264+ expect (editor .getText ()).toBe " text\n\n\n\n Paragraph-1\n Paragraph-1\n Paragraph-1\n\n\n moretext"
265+ expect (editor .getCursorScreenPosition ()).toEqual [1 , 0 ]
266+ expect (vimState .getRegister (' "' ).text ).toBe " \n\n\n Paragraph-1\n Paragraph-1\n Paragraph-1\n "
267+ expect (editorElement .classList .contains (' operator-pending-mode' )).toBe (false )
268+ expect (editorElement .classList .contains (' normal-mode' )).toBe (true )
269+
270+ it " selects around the next paragraph in visual mode when started from a blank/only-whitespace line" , ->
271+ editor .setText (" text\n\n\n\n paragraph-1\n paragraph-1\n paragraph-1\n\n\n moretext" )
272+ editor .setCursorBufferPosition ([1 , 0 ])
273+
274+ keydown (' v' )
275+ keydown (' a' )
276+ keydown (' p' )
277+
278+ expect (editor .getSelectedScreenRange ()).toEqual [[1 , 0 ], [7 , 0 ]]
237279
238280 describe " the 'i[' text object" , ->
239281 beforeEach ->
0 commit comments