@@ -630,6 +630,10 @@ describe('API', function()
630
630
end)
631
631
632
632
describe('nvim_paste', function()
633
+
before_each(function()
634
+
-- If nvim_paste() calls :undojoin without making any changes, this makes it an error.
635
+
feed('ifoo<Esc>u')
636
+
end)
633
637
it('validates args', function()
634
638
eq('Invalid phase: -2',
635
639
pcall_err(request, 'nvim_paste', 'foo', true, -2))
@@ -702,7 +706,7 @@ describe('API', function()
702
706
feed('u')
703
707
expect('||')
704
708
end)
705
-
it('stream: Visual mode either end not at the end of a line', function()
709
+
it('stream: Visual mode neither end at the end of a line', function()
706
710
feed('i|xxx<CR>xxx|<Esc>hvhk')
707
711
nvim('paste', 'aaaaaa', false, 1)
708
712
nvim('paste', 'bbbbbb', false, 2)
@@ -714,6 +718,30 @@ describe('API', function()
714
718
|xxx
715
719
xxx|]])
716
720
end)
721
+
it('stream: Visual mode neither end at the end of a line with empty first chunk', function()
722
+
feed('i|xxx<CR>xxx|<Esc>hvhk')
723
+
nvim('paste', '', false, 1)
724
+
nvim('paste', 'bbbbbb', false, 2)
725
+
nvim('paste', 'cccccc', false, 2)
726
+
nvim('paste', 'dddddd', false, 3)
727
+
expect('|bbbbbbccccccdddddd|')
728
+
feed('u')
729
+
expect([[
730
+
|xxx
731
+
xxx|]])
732
+
end)
733
+
it('stream: Visual mode neither end at the end of a line with all chunks empty', function()
734
+
feed('i|xxx<CR>xxx|<Esc>hvhk')
735
+
nvim('paste', '', false, 1)
736
+
nvim('paste', '', false, 2)
737
+
nvim('paste', '', false, 2)
738
+
nvim('paste', '', false, 3)
739
+
expect('||')
740
+
feed('u')
741
+
expect([[
742
+
|xxx
743
+
xxx|]])
744
+
end)
717
745
it('stream: Visual mode cursor at the end of a line', function()
718
746
feed('i||xxx<CR>xxx<Esc>vko')
719
747
nvim('paste', 'aaaaaa', false, 1)
@@ -726,6 +754,18 @@ describe('API', function()
726
754
||xxx
727
755
xxx]])
728
756
end)
757
+
it('stream: Visual mode cursor at the end of a line with empty first chunk', function()
758
+
feed('i||xxx<CR>xxx<Esc>vko')
759
+
nvim('paste', '', false, 1)
760
+
nvim('paste', 'bbbbbb', false, 2)
761
+
nvim('paste', 'cccccc', false, 2)
762
+
nvim('paste', 'dddddd', false, 3)
763
+
expect('||bbbbbbccccccdddddd')
764
+
feed('u')
765
+
expect([[
766
+
||xxx
767
+
xxx]])
768
+
end)
729
769
it('stream: Visual mode other end at the end of a line', function()
730
770
feed('i||xxx<CR>xxx<Esc>vk')
731
771
nvim('paste', 'aaaaaa', false, 1)
@@ -738,6 +778,18 @@ describe('API', function()
738
778
||xxx
739
779
xxx]])
740
780
end)
781
+
it('stream: Visual mode other end at the end of a line with empty first chunk', function()
782
+
feed('i||xxx<CR>xxx<Esc>vk')
783
+
nvim('paste', '', false, 1)
784
+
nvim('paste', 'bbbbbb', false, 2)
785
+
nvim('paste', 'cccccc', false, 2)
786
+
nvim('paste', 'dddddd', false, 3)
787
+
expect('||bbbbbbccccccdddddd')
788
+
feed('u')
789
+
expect([[
790
+
||xxx
791
+
xxx]])
792
+
end)
741
793
it('non-streaming', function()
742
794
-- With final "\n".
743
795
nvim('paste', 'line 1\nline 2\nline 3\n', true, -1)
@@ -817,6 +869,19 @@ describe('API', function()
817
869
eq('aabbccdd', funcs.getcmdline())
818
870
expect('')
819
871
end)
872
+
it('pasting with empty last chunk in Cmdline mode', function()
873
+
local screen = Screen.new(20, 4)
874
+
screen:attach()
875
+
feed(':')
876
+
nvim('paste', 'Foo', true, 1)
877
+
nvim('paste', '', true, 3)
878
+
screen:expect([[
879
+
|
880
+
~ |
881
+
~ |
882
+
:Foo^ |
883
+
]])
884
+
end)
820
885
it('crlf=false does not break lines at CR, CRLF', function()
821
886
nvim('paste', 'line 1\r\n\r\rline 2\nline 3\rline 4\r', false, -1)
822
887
expect('line 1\r\n\r\rline 2\nline 3\rline 4\r')
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4