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
|
-- ShaDa history saving/reading support
local helpers = require('test.functional.helpers')
local nvim, nvim_command, nvim_eval, nvim_feed, eq =
helpers.nvim, helpers.command, helpers.eval, helpers.feed, helpers.eq
local shada_helpers = require('test.functional.shada.helpers')
local reset, set_additional_cmd, clear =
shada_helpers.reset, shada_helpers.set_additional_cmd,
shada_helpers.clear
describe('ShaDa support code', function()
before_each(reset)
after_each(clear)
it('is able to dump and read back command-line history', function()
nvim_command('set viminfo=\'0')
nvim_feed(':" Test\n')
nvim_command('wviminfo')
reset()
nvim_command('set viminfo=\'0')
nvim_command('rviminfo')
eq('" Test', nvim_eval('histget(":", -1)'))
end)
it('is able to dump and read back 2 items in command-line history', function()
nvim_command('set viminfo=\'0 history=2')
nvim_feed(':" Test\n')
nvim_feed(':" Test 2\n')
nvim_command('qall')
reset()
nvim_command('set viminfo=\'0 history=2')
nvim_command('rviminfo')
eq('" Test 2', nvim_eval('histget(":", -1)'))
eq('" Test', nvim_eval('histget(":", -2)'))
nvim_command('qall')
end)
it('respects &history when dumping',
function()
nvim_command('set viminfo=\'0 history=1')
nvim_feed(':" Test\n')
nvim_feed(':" Test 2\n')
nvim_command('wviminfo')
reset()
nvim_command('set viminfo=\'0 history=2')
nvim_command('rviminfo')
eq('" Test 2', nvim_eval('histget(":", -1)'))
eq('', nvim_eval('histget(":", -2)'))
end)
it('respects &history when loading',
function()
nvim_command('set viminfo=\'0 history=2')
nvim_feed(':" Test\n')
nvim_feed(':" Test 2\n')
nvim_command('wviminfo')
reset()
nvim_command('set viminfo=\'0 history=1')
nvim_command('rviminfo')
eq('" Test 2', nvim_eval('histget(":", -1)'))
eq('', nvim_eval('histget(":", -2)'))
end)
it('dumps only requested amount of command-line history items', function()
nvim_command('set viminfo=\'0,:1')
nvim_feed(':" Test\n')
nvim_feed(':" Test 2\n')
nvim_command('wviminfo')
reset()
nvim_command('set viminfo=\'0')
nvim_command('rviminfo')
eq('" Test 2', nvim_eval('histget(":", -1)'))
eq('', nvim_eval('histget(":", -2)'))
end)
it('does not respect number in &viminfo when loading history', function()
nvim_command('set viminfo=\'0')
nvim_feed(':" Test\n')
nvim_feed(':" Test 2\n')
nvim_command('wviminfo')
reset()
nvim_command('set viminfo=\'0,:1')
nvim_command('rviminfo')
eq('" Test 2', nvim_eval('histget(":", -1)'))
eq('" Test', nvim_eval('histget(":", -2)'))
end)
it('dumps and loads all kinds of histories', function()
nvim_command('debuggreedy')
nvim_feed(':debug echo "Test"\n" Test 2\nc\n') -- Debug history.
nvim_feed(':call input("")\nTest 2\n') -- Input history.
nvim_feed('"="Test"\nyy') -- Expression history.
nvim_feed('/Test\n') -- Search history
nvim_feed(':" Test\n') -- Command-line history
nvim_command('0debuggreedy')
nvim_command('wviminfo')
reset()
nvim_command('rviminfo')
eq('" Test', nvim_eval('histget(":", -1)'))
eq('Test', nvim_eval('histget("/", -1)'))
eq('"Test"', nvim_eval('histget("=", -1)'))
eq('Test 2', nvim_eval('histget("@", -1)'))
eq('c', nvim_eval('histget(">", -1)'))
end)
it('dumps and loads last search pattern with offset', function()
nvim_eval('setline(".", ["foo", "bar"])')
nvim_feed('gg0/a/e+1\n')
eq({0, 2, 3, 0}, nvim_eval('getpos(".")'))
nvim_command('wviminfo')
reset()
nvim_eval('setline(".", ["foo", "bar"])')
nvim_feed('gg0n')
eq({0, 2, 3, 0}, nvim_eval('getpos(".")'))
end)
it('dumps and loads last substitute pattern and replacement string', function()
nvim_eval('setline(".", ["foo", "bar"])')
nvim_command('%s/f/g/g')
eq('goo', nvim_eval('getline(1)'))
nvim_command('wviminfo')
reset()
nvim_eval('setline(".", ["foo", "bar"])')
nvim_command('&')
eq('goo', nvim_eval('getline(1)'))
end)
end)
|