From bee666f239eada035d288b77269aebc42f644ea6 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 14 Jun 2016 20:39:42 +0200 Subject: [PATCH 1/4] patch 7.4.1935 Problem: When using the GUI search/replace a second match right after the replacement is skipped. Solution: Add the SEARCH_START flag. (Mleddy) --- src/gui.c | 9 +++++++-- src/version.c | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gui.c b/src/gui.c index d747d81179..6e8a9049e7 100644 --- a/src/gui.c +++ b/src/gui.c @@ -5348,10 +5348,15 @@ gui_do_findrepl( } else { - /* Search for the next match. */ + int searchflags = SEARCH_MSG + SEARCH_MARK; + + /* Search for the next match. + * Don't skip text under cursor for single replace. */ + if (type == FRD_REPLACE) + searchflags += SEARCH_START; i = msg_scroll; (void)do_search(NULL, down ? '/' : '?', ga.ga_data, 1L, - SEARCH_MSG + SEARCH_MARK, NULL); + searchflags, NULL); msg_scroll = i; /* don't let an error message set msg_scroll */ } diff --git a/src/version.c b/src/version.c index 44c517254f..3e22c3812e 100644 --- a/src/version.c +++ b/src/version.c @@ -753,6 +753,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1935, /**/ 1934, /**/ From 67e3720a9ddd8a9d2e8344358c28fa1f4196db0d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 14 Jun 2016 21:32:28 +0200 Subject: [PATCH 2/4] patch 7.4.1936 Problem: Off-by-one error in bounds check. (Coverity) Solution: Check register number properly. --- src/ops.c | 2 +- src/version.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ops.c b/src/ops.c index 44cd47366d..d97107e229 100644 --- a/src/ops.c +++ b/src/ops.c @@ -6011,7 +6011,7 @@ handle_viminfo_register(garray_T *values, int force) return; flags = vp[0].bv_nr; name = vp[1].bv_nr; - if (name < 0 || name > NUM_REGISTERS) + if (name < 0 || name >= NUM_REGISTERS) return; type = vp[2].bv_nr; if (type != MCHAR && type != MLINE && type != MBLOCK) diff --git a/src/version.c b/src/version.c index 3e22c3812e..32e78cc235 100644 --- a/src/version.c +++ b/src/version.c @@ -753,6 +753,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1936, /**/ 1935, /**/ From ab47c61f46f0797308217cd3c045472cb0ec3195 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 14 Jun 2016 22:02:26 +0200 Subject: [PATCH 3/4] patch 7.4.1937 Problem: No test for directory stack in quickfix. Solution: Add a test. (Yegappan Lakshmanan) --- src/testdir/test_quickfix.vim | 120 ++++++++++++++++++++++++++++------ src/version.c | 2 + 2 files changed, 103 insertions(+), 19 deletions(-) diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim index 6bcfa0c7ff..4e0b166849 100644 --- a/src/testdir/test_quickfix.vim +++ b/src/testdir/test_quickfix.vim @@ -80,9 +80,9 @@ function XageTests(cchar) let Xnewer = a:cchar . 'newer' let Xgetexpr = a:cchar . 'getexpr' if a:cchar == 'c' - let Xgetlist = 'getqflist()' + let Xgetlist = function('getqflist') else - let Xgetlist = 'getloclist(0)' + let Xgetlist = function('getloclist', [0]) endif " Jumping to a non existent list should return error @@ -99,21 +99,21 @@ function XageTests(cchar) " Go back two lists exe Xolder - exe 'let l = ' . Xgetlist + let l = Xgetlist() call assert_equal('Line2', l[0].text) " Go forward two lists exe Xnewer - exe 'let l = ' . Xgetlist + let l = Xgetlist() call assert_equal('Line3', l[0].text) " Test for the optional count argument exe Xolder . ' 2' - exe 'let l = ' . Xgetlist + let l = Xgetlist() call assert_equal('Line1', l[0].text) exe Xnewer . ' 2' - exe 'let l = ' . Xgetlist + let l = Xgetlist() call assert_equal('Line3', l[0].text) endfunction @@ -187,9 +187,9 @@ function XfileTests(cchar) let Xgetfile = a:cchar . 'getfile' let Xaddfile = a:cchar . 'addfile' if a:cchar == 'c' - let Xgetlist = 'getqflist()' + let Xgetlist = function('getqflist') else - let Xgetlist = 'getloclist(0)' + let Xgetlist = function('getloclist', [0]) endif call writefile(['Xtestfile1:700:10:Line 700', @@ -197,7 +197,7 @@ function XfileTests(cchar) enew! exe Xfile . ' Xqftestfile1' - exe 'let l = ' . Xgetlist + let l = Xgetlist() call assert_true(len(l) == 2 && \ l[0].lnum == 700 && l[0].col == 10 && l[0].text ==# 'Line 700' && \ l[1].lnum == 800 && l[1].col == 15 && l[1].text ==# 'Line 800') @@ -210,7 +210,7 @@ function XfileTests(cchar) call writefile(['Xtestfile3:900:30:Line 900'], 'Xqftestfile1') exe Xaddfile . ' Xqftestfile1' - exe 'let l = ' . Xgetlist + let l = Xgetlist() call assert_true(len(l) == 3 && \ l[2].lnum == 900 && l[2].col == 30 && l[2].text ==# 'Line 900') @@ -219,7 +219,7 @@ function XfileTests(cchar) enew! exe Xgetfile . ' Xqftestfile1' - exe 'let l = ' . Xgetlist + let l = Xgetlist() call assert_true(len(l) == 2 && \ l[0].lnum == 222 && l[0].col == 77 && l[0].text ==# 'Line 222' && \ l[1].lnum == 333 && l[1].col == 88 && l[1].text ==# 'Line 333') @@ -239,16 +239,16 @@ function XbufferTests(cchar) let Xgetbuffer = a:cchar . 'getbuffer' let Xaddbuffer = a:cchar . 'addbuffer' if a:cchar == 'c' - let Xgetlist = 'getqflist()' + let Xgetlist = function('getqflist') else - let Xgetlist = 'getloclist(0)' + let Xgetlist = function('getloclist', [0]) endif enew! silent! call setline(1, ['Xtestfile7:700:10:Line 700', \ 'Xtestfile8:800:15:Line 800']) exe Xbuffer . "!" - exe 'let l = ' . Xgetlist + let l = Xgetlist() call assert_true(len(l) == 2 && \ l[0].lnum == 700 && l[0].col == 10 && l[0].text ==# 'Line 700' && \ l[1].lnum == 800 && l[1].col == 15 && l[1].text ==# 'Line 800') @@ -257,7 +257,7 @@ function XbufferTests(cchar) silent! call setline(1, ['Xtestfile9:900:55:Line 900', \ 'Xtestfile10:950:66:Line 950']) exe Xgetbuffer - exe 'let l = ' . Xgetlist + let l = Xgetlist() call assert_true(len(l) == 2 && \ l[0].lnum == 900 && l[0].col == 55 && l[0].text ==# 'Line 900' && \ l[1].lnum == 950 && l[1].col == 66 && l[1].text ==# 'Line 950') @@ -266,11 +266,12 @@ function XbufferTests(cchar) silent! call setline(1, ['Xtestfile11:700:20:Line 700', \ 'Xtestfile12:750:25:Line 750']) exe Xaddbuffer - exe 'let l = ' . Xgetlist + let l = Xgetlist() call assert_true(len(l) == 4 && \ l[1].lnum == 950 && l[1].col == 66 && l[1].text ==# 'Line 950' && \ l[2].lnum == 700 && l[2].col == 20 && l[2].text ==# 'Line 700' && \ l[3].lnum == 750 && l[3].col == 25 && l[3].text ==# 'Line 750') + enew! endfunction @@ -339,15 +340,15 @@ endfunc function XqfTitleTests(cchar) let Xgetexpr = a:cchar . 'getexpr' if a:cchar == 'c' - let Xgetlist = 'getqflist()' + let Xgetlist = function('getqflist') else - let Xgetlist = 'getloclist(0)' + let Xgetlist = function('getloclist', [0]) endif let Xopen = a:cchar . 'open' let Xclose = a:cchar . 'close' exe Xgetexpr . " ['file:1:1:message']" - exe 'let l = ' . Xgetlist + let l = Xgetlist() if a:cchar == 'c' call setqflist(l, 'r') else @@ -638,6 +639,87 @@ function! Test_efm1() call delete('Xtestfile') endfunction +" Test for quickfix directory stack support +function! s:dir_stack_tests(cchar) + let Xgetexpr = a:cchar . 'getexpr' + if a:cchar == 'c' + let Xgetlist = function('getqflist') + else + let Xgetlist = function('getloclist', [0]) + endif + + let save_efm=&efm + set efm=%DEntering\ dir\ '%f',%f:%l:%m,%XLeaving\ dir\ '%f' + + let l = "Entering dir 'dir1/a'\n" . + \ 'habits2.txt:1:Nine Healthy Habits' . "\n" . + \ "Entering dir 'b'\n" . + \ 'habits3.txt:2:0 Hours of television' . "\n" . + \ 'habits2.txt:7:5 Small meals' . "\n" . + \ "Entering dir 'dir1/c'\n" . + \ 'habits4.txt:3:1 Hour of exercise' . "\n" . + \ "Leaving dir 'dir1/c'\n" . + \ "Leaving dir 'dir1/a'\n" . + \ 'habits1.txt:4:2 Liters of water' . "\n" . + \ "Entering dir 'dir2'\n" . + \ 'habits5.txt:5:3 Cups of hot green tea' . "\n" . + \ "Leaving dir 'dir2'\n" + + exe Xgetexpr . " l" + + let qf = Xgetlist() + + call assert_equal('dir1/a/habits2.txt', bufname(qf[1].bufnr)) + call assert_equal(1, qf[1].lnum) + call assert_equal('dir1/a/b/habits3.txt', bufname(qf[3].bufnr)) + call assert_equal(2, qf[3].lnum) + call assert_equal('dir1/a/habits2.txt', bufname(qf[4].bufnr)) + call assert_equal(7, qf[4].lnum) + call assert_equal('dir1/c/habits4.txt', bufname(qf[6].bufnr)) + call assert_equal(3, qf[6].lnum) + call assert_equal('habits1.txt', bufname(qf[9].bufnr)) + call assert_equal(4, qf[9].lnum) + call assert_equal('dir2/habits5.txt', bufname(qf[11].bufnr)) + call assert_equal(5, qf[11].lnum) + + let &efm=save_efm +endfunction + +" Tests for %D and %X errorformat options +function! Test_efm_dirstack() + " Create the directory stack and files + call mkdir('dir1') + call mkdir('dir1/a') + call mkdir('dir1/a/b') + call mkdir('dir1/c') + call mkdir('dir2') + + let lines = ["Nine Healthy Habits", + \ "0 Hours of television", + \ "1 Hour of exercise", + \ "2 Liters of water", + \ "3 Cups of hot green tea", + \ "4 Short mental breaks", + \ "5 Small meals", + \ "6 AM wake up time", + \ "7 Minutes of laughter", + \ "8 Hours of sleep (at least)", + \ "9 PM end of the day and off to bed" + \ ] + call writefile(lines, 'habits1.txt') + call writefile(lines, 'dir1/a/habits2.txt') + call writefile(lines, 'dir1/a/b/habits3.txt') + call writefile(lines, 'dir1/c/habits4.txt') + call writefile(lines, 'dir2/habits5.txt') + + call s:dir_stack_tests('c') + call s:dir_stack_tests('l') + + call delete('dir1', 'rf') + call delete('dir2', 'rf') + call delete('habits1.txt') +endfunction + function XquickfixChangedByAutocmd(cchar) let Xolder = a:cchar . 'older' let Xgetexpr = a:cchar . 'getexpr' diff --git a/src/version.c b/src/version.c index 32e78cc235..2cdd14245f 100644 --- a/src/version.c +++ b/src/version.c @@ -753,6 +753,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1937, /**/ 1936, /**/ From 36f0f0686ca313ef7b76387378cd5dc7acea1924 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 14 Jun 2016 23:02:46 +0200 Subject: [PATCH 4/4] patch 7.4.1938 Problem: When writing viminfo numbered marks were duplicated. Solution: Check for duplicates between current numbered marks and the ones read from viminfo. --- src/mark.c | 24 ++++++++++++++++++++---- src/version.c | 2 ++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/mark.c b/src/mark.c index 008a0d0fec..5e2ac55071 100644 --- a/src/mark.c +++ b/src/mark.c @@ -1674,13 +1674,29 @@ write_viminfo_filemarks(FILE *fp) idx = NMARKS; for (i = NMARKS; i < NMARKS + EXTRA_MARKS; i++) { - if (vi_namedfm != NULL - && vi_namedfm[vi_idx].fmark.mark.lnum != 0 - && (vi_namedfm[vi_idx].time_set > namedfm[idx].time_set + xfmark_T *vi_fm = vi_namedfm != NULL ? &vi_namedfm[vi_idx] : NULL; + + if (vi_fm != NULL + && vi_fm->fmark.mark.lnum != 0 + && (vi_fm->time_set > namedfm[idx].time_set || namedfm[idx].fmark.mark.lnum == 0)) - fm = &vi_namedfm[vi_idx++]; + { + fm = vi_fm; + ++vi_idx; + } else + { fm = &namedfm[idx++]; + if (vi_fm != NULL + && vi_fm->fmark.mark.lnum == fm->fmark.mark.lnum + && vi_fm->time_set == fm->time_set + && ((vi_fm->fmark.fnum != 0 + && vi_fm->fmark.fnum == fm->fmark.fnum) + || (vi_fm->fname != NULL + && fm->fname != NULL + && STRCMP(vi_fm->fname, fm->fname) == 0))) + ++vi_idx; /* skip duplicate */ + } write_one_filemark(fp, fm, '\'', i - NMARKS + '0'); } diff --git a/src/version.c b/src/version.c index 2cdd14245f..1a2b1f3c26 100644 --- a/src/version.c +++ b/src/version.c @@ -753,6 +753,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1938, /**/ 1937, /**/