Skip to content

Commit 119d469

Browse files
committed
patch 7.4.1494
Problem: clr_history() does not work properly. Solution: Increment hisptr. Add a test. (Yegappan Lakshmanan)
1 parent 5983ad0 commit 119d469

4 files changed

Lines changed: 69 additions & 0 deletions

File tree

src/ex_getln.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5783,6 +5783,7 @@ clr_history(int histype)
57835783
{
57845784
vim_free(hisptr->hisstr);
57855785
clear_hist_entry(hisptr);
5786+
hisptr++;
57865787
}
57875788
hisidx[histype] = -1; /* mark history as cleared */
57885789
hisnum[histype] = 0; /* reset identifier counter */

src/testdir/Make_all.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ NEW_TESTS = test_arglist.res \
175175
test_cdo.res \
176176
test_channel.res \
177177
test_hardcopy.res \
178+
test_history.res \
178179
test_increment.res \
179180
test_json.res \
180181
test_langmap.res \

src/testdir/test_history.vim

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
" Tests for the history functions
2+
3+
if !has('cmdline_hist')
4+
finish
5+
endif
6+
7+
set history=7
8+
9+
function History_Tests(hist)
10+
" First clear the history
11+
call histadd(a:hist, 'dummy')
12+
call assert_true(histdel(a:hist))
13+
call assert_equal(-1, histnr(a:hist))
14+
call assert_equal('', histget(a:hist))
15+
16+
call assert_true(histadd(a:hist, 'ls'))
17+
call assert_true(histadd(a:hist, 'buffers'))
18+
call assert_equal('buffers', histget(a:hist))
19+
call assert_equal('ls', histget(a:hist, -2))
20+
call assert_equal('ls', histget(a:hist, 1))
21+
call assert_equal('', histget(a:hist, 5))
22+
call assert_equal('', histget(a:hist, -5))
23+
call assert_equal(2, histnr(a:hist))
24+
call assert_true(histdel(a:hist, 2))
25+
call assert_false(histdel(a:hist, 7))
26+
call assert_equal(1, histnr(a:hist))
27+
call assert_equal('ls', histget(a:hist, -1))
28+
29+
call assert_true(histadd(a:hist, 'buffers'))
30+
call assert_true(histadd(a:hist, 'ls'))
31+
call assert_equal('ls', histget(a:hist, -1))
32+
call assert_equal(4, histnr(a:hist))
33+
34+
" Test for removing entries matching a pattern
35+
for i in range(1, 3)
36+
call histadd(a:hist, 'text_' . i)
37+
endfor
38+
call assert_true(histdel(a:hist, 'text_\d\+'))
39+
call assert_equal('ls', histget(a:hist, -1))
40+
41+
" Test for freeing the entire history list
42+
for i in range(1, 7)
43+
call histadd(a:hist, 'text_' . i)
44+
endfor
45+
call histdel(a:hist)
46+
for i in range(1, 7)
47+
call assert_equal('', histget(a:hist, i))
48+
call assert_equal('', histget(a:hist, i - 7 - 1))
49+
endfor
50+
endfunction
51+
52+
function Test_History()
53+
for h in ['cmd', ':', '', 'search', '/', '?', 'expr', '=', 'input', '@', 'debug', '>']
54+
call History_Tests(h)
55+
endfor
56+
57+
" Negative tests
58+
call assert_false(histdel('abc'))
59+
call assert_equal('', histget('abc'))
60+
call assert_fails('call histdel([])', 'E730:')
61+
call assert_equal('', histget(10))
62+
call assert_fails('call histget([])', 'E730:')
63+
call assert_equal(-1, histnr('abc'))
64+
call assert_fails('call histnr([])', 'E730:')
65+
endfunction

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,8 @@ static char *(features[]) =
743743

744744
static int included_patches[] =
745745
{ /* Add new patch number below this line */
746+
/**/
747+
1494,
746748
/**/
747749
1493,
748750
/**/

0 commit comments

Comments
 (0)