From 24a2d416ec261829ff7fd29f7b66739c96dd6513 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 24 Jan 2017 17:48:36 +0100 Subject: [PATCH 1/9] patch 8.0.0229: local 'formatprg' option value leaks Problem: When freeing a buffer the local value of the 'formatprg' option is not cleared. Solution: Add missing change. --- src/buffer.c | 1 + src/version.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/buffer.c b/src/buffer.c index b79e277a01..b2c914d7a8 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -2153,6 +2153,7 @@ free_buf_options( #if defined(FEAT_CRYPT) clear_string_option(&buf->b_p_cm); #endif + clear_string_option(&buf->b_p_fp); #if defined(FEAT_EVAL) clear_string_option(&buf->b_p_fex); #endif diff --git a/src/version.c b/src/version.c index 6d3b8483f7..829b3b94c8 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 229, /**/ 228, /**/ From 915350edec02f0326ecbe49f3b6cf2cbcd105f7d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 24 Jan 2017 17:50:52 +0100 Subject: [PATCH 2/9] patch 8.0.0230: bracketed paste does not support line breaks Problem: When using bracketed paste line breaks are not respected. Solution: Turn CR characters into a line break if the text is being inserted. (closes #1404) --- src/edit.c | 6 +++++- src/version.c | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/edit.c b/src/edit.c index 61d92170f4..ce6abaf209 100644 --- a/src/edit.c +++ b/src/edit.c @@ -9498,7 +9498,11 @@ bracketed_paste(paste_mode_T mode, int drop, garray_T *gap) case PASTE_INSERT: if (stop_arrow() == OK) { - ins_char_bytes(buf, idx); + c = buf[0]; + if (idx == 1 && (c == CAR || c == K_KENTER || c == NL)) + ins_eol(c); + else + ins_char_bytes(buf, idx); AppendToRedobuffLit(buf, idx); } break; diff --git a/src/version.c b/src/version.c index 829b3b94c8..c7528b7d97 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 230, /**/ 229, /**/ From 076e502199b19e6141e4c1e659ff3f21b71934e1 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 24 Jan 2017 18:58:30 +0100 Subject: [PATCH 3/9] patch 8.0.0231: bracketed paste mode is not tested Problem: There are no tests for bracketed paste mode. Solution: Add a test. Fix repeating with "normal .". --- src/Makefile | 3 ++- src/edit.c | 9 +++++++-- src/testdir/Make_all.mak | 1 + src/testdir/test_paste.vim | 41 ++++++++++++++++++++++++++++++++++++++ src/version.c | 2 ++ 5 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 src/testdir/test_paste.vim diff --git a/src/Makefile b/src/Makefile index 8de7104d5d..a588219946 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2147,6 +2147,7 @@ test_arglist \ test_options \ test_packadd \ test_partial \ + test_paste \ test_perl \ test_popup \ test_profile \ @@ -2161,9 +2162,9 @@ test_arglist \ test_searchpos \ test_set \ test_signs \ + test_smartindent \ test_sort \ test_source_utf8 \ - test_smartindent \ test_startup \ test_startup_utf8 \ test_stat \ diff --git a/src/edit.c b/src/edit.c index ce6abaf209..9e6cc3e8bf 100644 --- a/src/edit.c +++ b/src/edit.c @@ -463,7 +463,10 @@ edit( else #endif { - AppendCharToRedobuff(cmdchar); + if (cmdchar == K_PS) + AppendCharToRedobuff('a'); + else + AppendCharToRedobuff(cmdchar); if (cmdchar == 'g') /* "gI" command */ AppendCharToRedobuff('I'); else if (cmdchar == 'r') /* "r" command */ @@ -9502,8 +9505,10 @@ bracketed_paste(paste_mode_T mode, int drop, garray_T *gap) if (idx == 1 && (c == CAR || c == K_KENTER || c == NL)) ins_eol(c); else + { ins_char_bytes(buf, idx); - AppendToRedobuffLit(buf, idx); + AppendToRedobuffLit(buf, idx); + } } break; diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak index e0da1b408d..613b86804e 100644 --- a/src/testdir/Make_all.mak +++ b/src/testdir/Make_all.mak @@ -173,6 +173,7 @@ NEW_TESTS = test_arglist.res \ test_nested_function.res \ test_netbeans.res \ test_normal.res \ + test_paste.res \ test_packadd.res \ test_perl.res \ test_profile.res \ diff --git a/src/testdir/test_paste.vim b/src/testdir/test_paste.vim new file mode 100644 index 0000000000..ffd2dfa32f --- /dev/null +++ b/src/testdir/test_paste.vim @@ -0,0 +1,41 @@ +" Tests for bracketed paste. + +" Bracketed paste only works with "xterm". +set term=xterm + +func Test_paste_normal_mode() + new + call setline(1, ['a', 'b', 'c']) + 2 + call feedkeys("\[200~foo\bar\[201~", 'xt') + call assert_equal('bfoo', getline(2)) + call assert_equal('bar', getline(3)) + call assert_equal('c', getline(4)) + + normal . + call assert_equal('barfoo', getline(3)) + call assert_equal('bar', getline(4)) + call assert_equal('c', getline(5)) + bwipe! +endfunc + +func Test_paste_insert_mode() + new + call setline(1, ['a', 'b', 'c']) + 2 + call feedkeys("i\[200~foo\bar\[201~ done\", 'xt') + call assert_equal('foo', getline(2)) + call assert_equal('bar doneb', getline(3)) + call assert_equal('c', getline(4)) + + normal . + call assert_equal('bar donfoo', getline(3)) + call assert_equal('bar doneeb', getline(4)) + call assert_equal('c', getline(5)) + bwipe! +endfunc + +func Test_paste_cmdline() + call feedkeys(":a\[200~foo\bar\[201~b\\"\", 'xt') + call assert_equal("\"afoo\barb", getreg(':')) +endfunc diff --git a/src/version.c b/src/version.c index c7528b7d97..190a67dad1 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 231, /**/ 230, /**/ From 48c9f3b123364f368472564a66a9b71dc383558b Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 24 Jan 2017 19:08:15 +0100 Subject: [PATCH 4/9] patch 8.0.0232: paste does not work when 'esckeys' is off Problem: Pasting in Insert mode does not work when bracketed paste is used and 'esckeys' is off. Solution: When 'esckeys' is off disable bracketed paste in Insert mode. --- src/edit.c | 7 +++++++ src/version.c | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/edit.c b/src/edit.c index 9e6cc3e8bf..2e1aa2beac 100644 --- a/src/edit.c +++ b/src/edit.c @@ -534,6 +534,10 @@ edit( revins_legal = 0; revins_scol = -1; #endif + if (!p_ek) + /* Disable bracketed paste mode, we won't recognize the escape + * sequences. */ + out_str(T_BD); /* * Handle restarting Insert mode. @@ -8623,6 +8627,9 @@ ins_esc( #ifdef CURSOR_SHAPE ui_cursor_shape(); /* may show different cursor shape */ #endif + if (!p_ek) + /* Re-enable bracketed paste mode. */ + out_str(T_BE); /* * When recording or for CTRL-O, need to display the new mode. diff --git a/src/version.c b/src/version.c index 190a67dad1..c7ef2bec56 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 232, /**/ 231, /**/ From bff6ad133195145f810645c0bde7a2a1fdfc37b8 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 24 Jan 2017 19:18:13 +0100 Subject: [PATCH 5/9] patch 8.0.0233: paste test fails in the GUI Problem: The paste test fails if the GUI is being used. Solution: Skip the test in the GUI. --- src/testdir/test_paste.vim | 5 ++++- src/version.c | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/testdir/test_paste.vim b/src/testdir/test_paste.vim index ffd2dfa32f..dfe6bdc875 100644 --- a/src/testdir/test_paste.vim +++ b/src/testdir/test_paste.vim @@ -1,6 +1,9 @@ " Tests for bracketed paste. -" Bracketed paste only works with "xterm". +" Bracketed paste only works with "xterm". Not in GUI. +if has('gui_running') + finish +endif set term=xterm func Test_paste_normal_mode() diff --git a/src/version.c b/src/version.c index c7ef2bec56..1b78243549 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 233, /**/ 232, /**/ From 941c12da3c087fd04aa6c120a76bf28f19349d96 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 24 Jan 2017 19:55:43 +0100 Subject: [PATCH 6/9] patch 8.0.0234: crash when using put in Visual mode Problem: When several lines are visually selected and one of them is short, using put may cause a crash. (Axel Bender) Solution: Check for a short line. (Christian Brabandt) --- src/ops.c | 15 ++++++++++++--- src/testdir/test_put.vim | 13 +++++++++++++ src/version.c | 2 ++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/ops.c b/src/ops.c index 1abb8daa1f..2aee03deff 100644 --- a/src/ops.c +++ b/src/ops.c @@ -3774,16 +3774,25 @@ do_put( */ if (y_type == MCHAR && y_size == 1) { - linenr_T end = curbuf->b_visual.vi_end.lnum; + linenr_T end; - if (curbuf->b_visual.vi_end.lnum < curbuf->b_visual.vi_start.lnum) - end = curbuf->b_visual.vi_start.lnum; + if (VIsual_active) + { + end = curbuf->b_visual.vi_end.lnum; + if (end < curbuf->b_visual.vi_start.lnum) + end = curbuf->b_visual.vi_start.lnum; + } do { totlen = count * yanklen; if (totlen > 0) { oldp = ml_get(lnum); + if (VIsual_active && col > (int)STRLEN(oldp)) + { + lnum++; + continue; + } newp = alloc_check((unsigned)(STRLEN(oldp) + totlen + 1)); if (newp == NULL) goto end; /* alloc() gave an error message */ diff --git a/src/testdir/test_put.vim b/src/testdir/test_put.vim index 0154de1ec0..38c812bc9c 100644 --- a/src/testdir/test_put.vim +++ b/src/testdir/test_put.vim @@ -21,3 +21,16 @@ func Test_put_char_block() call assert_equal(['Xfile_put 1', 'Xfile_put 2'], getline(1,2)) bw! endfunc + +func Test_put_char_block2() + new + let a = [ getreg('a'), getregtype('a') ] + call setreg('a', ' one ', 'v') + call setline(1, ['Line 1', '', 'Line 3', '']) + " visually select the first 3 lines and put register a over it + exe "norm! ggl\2j2l\"ap" + call assert_equal(['L one 1', '', 'L one 3', ''], getline(1,4)) + " clean up + bw! + call setreg('a', a[0], a[1]) +endfunc diff --git a/src/version.c b/src/version.c index 1b78243549..8622e6d17a 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 234, /**/ 233, /**/ From b031c4ea04eb1e37a873fbb85e90d835aa1e2b1c Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 24 Jan 2017 20:14:48 +0100 Subject: [PATCH 7/9] patch 8.0.0235: memory leak in diff mode Problem: Memory leak detected when running tests for diff mode. Solution: Free p_extra_free. --- src/screen.c | 4 ++++ src/version.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/screen.c b/src/screen.c index 016e7ee3e9..e37bf48382 100644 --- a/src/screen.c +++ b/src/screen.c @@ -3651,6 +3651,7 @@ win_line( { /* Draw the 'foldcolumn'. Allocate a buffer, "extra" may * already be in use. */ + vim_free(p_extra_free); p_extra_free = alloc(12 + 1); if (p_extra_free != NULL) @@ -4695,6 +4696,7 @@ win_line( p = alloc((unsigned)(len + 1)); vim_memset(p, ' ', len); p[len] = NUL; + vim_free(p_extra_free); p_extra_free = p; for (i = 0; i < tab_len; i++) { @@ -4857,6 +4859,7 @@ win_line( vim_memset(p, ' ', n_extra); STRNCPY(p, p_extra + 1, STRLEN(p_extra) - 1); p[n_extra] = NUL; + vim_free(p_extra_free); p_extra_free = p_extra = p; } else @@ -5784,6 +5787,7 @@ win_line( } #endif + vim_free(p_extra_free); return row; } diff --git a/src/version.c b/src/version.c index 8622e6d17a..65208d0a0e 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 235, /**/ 234, /**/ From 6a717f17ec6b09634be1c29e0ac4c35213f7b32d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 24 Jan 2017 20:47:50 +0100 Subject: [PATCH 8/9] patch 8.0.0236: gcc complains about uninitialized variable Problem: Gcc complains that a variable may be used uninitialized. Confusion between variable and label name. (John Marriott) Solution: Initialize it. Rename end to end_lnum. --- src/ops.c | 10 +++++----- src/version.c | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ops.c b/src/ops.c index 2aee03deff..7d656a6313 100644 --- a/src/ops.c +++ b/src/ops.c @@ -3774,13 +3774,13 @@ do_put( */ if (y_type == MCHAR && y_size == 1) { - linenr_T end; + linenr_T end_lnum = 0; /* init for gcc */ if (VIsual_active) { - end = curbuf->b_visual.vi_end.lnum; - if (end < curbuf->b_visual.vi_start.lnum) - end = curbuf->b_visual.vi_start.lnum; + end_lnum = curbuf->b_visual.vi_end.lnum; + if (end_lnum < curbuf->b_visual.vi_start.lnum) + end_lnum = curbuf->b_visual.vi_start.lnum; } do { @@ -3815,7 +3815,7 @@ do_put( } if (VIsual_active) lnum++; - } while (VIsual_active && lnum <= end); + } while (VIsual_active && lnum <= end_lnum); if (VIsual_active) /* reset lnum to the last visual line */ lnum--; diff --git a/src/version.c b/src/version.c index 65208d0a0e..684a244cd9 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 236, /**/ 235, /**/ From ba47b51ff88d91c9bb5aa522183e23a656865697 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 24 Jan 2017 21:18:19 +0100 Subject: [PATCH 9/9] patch 8.0.0237: when 'wildoptions' is "tagfile" completion may not work Problem: When setting wildoptions=tagfile the completion context is not set correctly. (desjardins) Solution: Check for EXPAND_TAGS_LISTFILES. (Christian Brabandt, closes #1399) --- src/ex_getln.c | 4 +++- src/testdir/test_cmdline.vim | 11 +++++++++++ src/version.c | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/ex_getln.c b/src/ex_getln.c index 7de7246b55..4365100a2b 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -4366,7 +4366,9 @@ addstar( || context == EXPAND_OWNSYNTAX || context == EXPAND_FILETYPE || context == EXPAND_PACKADD - || (context == EXPAND_TAGS && fname[0] == '/')) + || ((context == EXPAND_TAGS_LISTFILES + || context == EXPAND_TAGS) + && fname[0] == '/')) retval = vim_strnsave(fname, len); else { diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim index 279a1681c4..fcfce7354d 100644 --- a/src/testdir/test_cmdline.vim +++ b/src/testdir/test_cmdline.vim @@ -295,3 +295,14 @@ func Test_illegal_address() 2;') quit endfunc + +func Test_cmdline_complete_wildoptions() + help + call feedkeys(":tag /\\\"\", 'tx') + let a = join(sort(split(@:)),' ') + set wildoptions=tagfile + call feedkeys(":tag /\\\"\", 'tx') + let b = join(sort(split(@:)),' ') + call assert_equal(a, b) + bw! +endfunc diff --git a/src/version.c b/src/version.c index 684a244cd9..68ea529097 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 237, /**/ 236, /**/