To: vim_dev@googlegroups.com Subject: Patch 7.4.1494 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1494 Problem: clr_history() does not work properly. Solution: Increment hisptr. Add a test. (Yegappan Lakshmanan) Files: src/ex_getln.c, src/testdir/test_history.vim, src/testdir/Make_all.mak *** ../vim-7.4.1493/src/ex_getln.c 2016-03-05 17:41:43.109188989 +0100 --- src/ex_getln.c 2016-03-05 21:00:41.732634808 +0100 *************** *** 5783,5788 **** --- 5783,5789 ---- { vim_free(hisptr->hisstr); clear_hist_entry(hisptr); + hisptr++; } hisidx[histype] = -1; /* mark history as cleared */ hisnum[histype] = 0; /* reset identifier counter */ *** ../vim-7.4.1493/src/testdir/test_history.vim 2016-03-05 21:20:37.888048678 +0100 --- src/testdir/test_history.vim 2016-03-05 20:59:45.425226949 +0100 *************** *** 0 **** --- 1,65 ---- + " Tests for the history functions + + if !has('cmdline_hist') + finish + endif + + set history=7 + + function History_Tests(hist) + " First clear the history + call histadd(a:hist, 'dummy') + call assert_true(histdel(a:hist)) + call assert_equal(-1, histnr(a:hist)) + call assert_equal('', histget(a:hist)) + + call assert_true(histadd(a:hist, 'ls')) + call assert_true(histadd(a:hist, 'buffers')) + call assert_equal('buffers', histget(a:hist)) + call assert_equal('ls', histget(a:hist, -2)) + call assert_equal('ls', histget(a:hist, 1)) + call assert_equal('', histget(a:hist, 5)) + call assert_equal('', histget(a:hist, -5)) + call assert_equal(2, histnr(a:hist)) + call assert_true(histdel(a:hist, 2)) + call assert_false(histdel(a:hist, 7)) + call assert_equal(1, histnr(a:hist)) + call assert_equal('ls', histget(a:hist, -1)) + + call assert_true(histadd(a:hist, 'buffers')) + call assert_true(histadd(a:hist, 'ls')) + call assert_equal('ls', histget(a:hist, -1)) + call assert_equal(4, histnr(a:hist)) + + " Test for removing entries matching a pattern + for i in range(1, 3) + call histadd(a:hist, 'text_' . i) + endfor + call assert_true(histdel(a:hist, 'text_\d\+')) + call assert_equal('ls', histget(a:hist, -1)) + + " Test for freeing the entire history list + for i in range(1, 7) + call histadd(a:hist, 'text_' . i) + endfor + call histdel(a:hist) + for i in range(1, 7) + call assert_equal('', histget(a:hist, i)) + call assert_equal('', histget(a:hist, i - 7 - 1)) + endfor + endfunction + + function Test_History() + for h in ['cmd', ':', '', 'search', '/', '?', 'expr', '=', 'input', '@', 'debug', '>'] + call History_Tests(h) + endfor + + " Negative tests + call assert_false(histdel('abc')) + call assert_equal('', histget('abc')) + call assert_fails('call histdel([])', 'E730:') + call assert_equal('', histget(10)) + call assert_fails('call histget([])', 'E730:') + call assert_equal(-1, histnr('abc')) + call assert_fails('call histnr([])', 'E730:') + endfunction *** ../vim-7.4.1493/src/testdir/Make_all.mak 2016-03-05 17:25:34.791256346 +0100 --- src/testdir/Make_all.mak 2016-03-05 20:59:45.425226949 +0100 *************** *** 175,180 **** --- 175,181 ---- test_cdo.res \ test_channel.res \ test_hardcopy.res \ + test_history.res \ test_increment.res \ test_json.res \ test_langmap.res \ *** ../vim-7.4.1493/src/version.c 2016-03-05 20:54:28.220563734 +0100 --- src/version.c 2016-03-05 21:02:16.819634968 +0100 *************** *** 745,746 **** --- 745,748 ---- { /* Add new patch number below this line */ + /**/ + 1494, /**/ -- The only way the average employee can speak to an executive is by taking a second job as a golf caddie. (Scott Adams - The Dilbert principle) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///