From 907dad72ef9d29422352fb74ba156e7085a3fc71 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 10 Jul 2018 15:07:15 +0200 Subject: [PATCH 1/5] patch 8.1.0174: after paging up and down fold line is wrong Problem: After paging up and down fold line is wrong. Solution: Correct the computation of w_topline and w_botline. (Hirohito Higashi) --- src/move.c | 27 ++++++++++++++++----------- src/testdir/test_fold.vim | 26 ++++++++++++++++++++++++++ src/version.c | 2 ++ 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/src/move.c b/src/move.c index a56003013c..b2b84868ac 100644 --- a/src/move.c +++ b/src/move.c @@ -2457,22 +2457,27 @@ onepage(int dir, long count) beginline(BL_SOL | BL_FIX); curwin->w_valid &= ~(VALID_WCOL|VALID_WROW|VALID_VIRTCOL); - /* - * Avoid the screen jumping up and down when 'scrolloff' is non-zero. - * But make sure we scroll at least one line (happens with mix of long - * wrapping lines and non-wrapping line). - */ - if (retval == OK && dir == FORWARD && check_top_offset()) + if (retval == OK && dir == FORWARD) { - scroll_cursor_top(1, FALSE); - if (curwin->w_topline <= old_topline - && old_topline < curbuf->b_ml.ml_line_count) + // Avoid the screen jumping up and down when 'scrolloff' is non-zero. + // But make sure we scroll at least one line (happens with mix of long + // wrapping lines and non-wrapping line). + if (check_top_offset()) { - curwin->w_topline = old_topline + 1; + scroll_cursor_top(1, FALSE); + if (curwin->w_topline <= old_topline + && old_topline < curbuf->b_ml.ml_line_count) + { + curwin->w_topline = old_topline + 1; #ifdef FEAT_FOLDING + (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL); +#endif + } + } +#ifdef FEAT_FOLDING + else if (curwin->w_botline > curbuf->b_ml.ml_line_count) (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL); #endif - } } redraw_later(VALID); diff --git a/src/testdir/test_fold.vim b/src/testdir/test_fold.vim index de6688365d..df4b12c8ce 100644 --- a/src/testdir/test_fold.vim +++ b/src/testdir/test_fold.vim @@ -1,5 +1,7 @@ " Test for folding +source view_util.vim + func PrepIndent(arg) return [a:arg] + repeat(["\t".a:arg], 5) endfu @@ -648,3 +650,27 @@ func Test_foldopen_exception() endtry call assert_match('E492:', a) endfunc + +func Test_fold_last_line_with_pagedown() + enew! + set fdm=manual + + let expect = '+-- 11 lines: 9---' + let content = range(1,19) + call append(0, content) + normal dd9G + normal zfG + normal zt + call assert_equal('9', getline(foldclosed('.'))) + call assert_equal('19', getline(foldclosedend('.'))) + call assert_equal(expect, ScreenLines(1, len(expect))[0]) + call feedkeys("\", 'xt') + call assert_equal(expect, ScreenLines(1, len(expect))[0]) + call feedkeys("\", 'xt') + call assert_equal(expect, ScreenLines(1, len(expect))[0]) + call feedkeys("\\\", 'xt') + call assert_equal(expect, ScreenLines(1, len(expect))[0]) + + set fdm& + enew! +endfunc diff --git a/src/version.c b/src/version.c index de6f550dd6..6b422e6703 100644 --- a/src/version.c +++ b/src/version.c @@ -789,6 +789,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 174, /**/ 173, /**/ From bde14d8e24f6b8ca409290733dbf11cb6fee5751 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 10 Jul 2018 15:22:32 +0200 Subject: [PATCH 2/5] patch 8.1.0175: marks test fails in very wide window Problem: Marks test fails in very wide window. (Vladimir Lomov) Solution: Extend the text to match 'columns'. (closes #3180, closes #3181) --- src/testdir/test_marks.vim | 7 ++----- src/version.c | 2 ++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/testdir/test_marks.vim b/src/testdir/test_marks.vim index b05246e064..8858cd22b8 100644 --- a/src/testdir/test_marks.vim +++ b/src/testdir/test_marks.vim @@ -126,15 +126,12 @@ func Test_marks_cmd_multibyte() return endif new Xone - call setline(1, ['ááááááááááááááááááááááááááááááááááááááááááááááááááááááááááááááááááááááááááááááááá']) + call setline(1, [repeat('á', &columns)]) norm! ma let a = split(execute('marks a'), "\n") call assert_equal(2, len(a)) - let expected = ' a 1 0 ' - while strwidth(expected) < &columns - 1 - let expected .= 'á' - endwhile + let expected = ' a 1 0 ' . repeat('á', &columns - 16) call assert_equal(expected, a[1]) bwipe! diff --git a/src/version.c b/src/version.c index 6b422e6703..58751e3215 100644 --- a/src/version.c +++ b/src/version.c @@ -789,6 +789,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 175, /**/ 174, /**/ From 18085fae7482906f8e94ecc7386ecf6a02dc407d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 10 Jul 2018 17:33:45 +0200 Subject: [PATCH 3/5] patch 8.1.0176: overlapping string argument for strcpy() Problem: Overlapping string argument for strcpy(). (Coverity) Solution: Use STRMOVE() instead of STRCPY(). (Dominique Pelle, closes #3187) --- src/term.c | 2 +- src/version.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/term.c b/src/term.c index 21f9a3cfa7..209a03f5c1 100644 --- a/src/term.c +++ b/src/term.c @@ -1483,7 +1483,7 @@ parse_builtin_tcap(char_u *term) if (term_7to8bit(t)) { *t = term_7to8bit(t); - STRCPY(t + 1, t + 2); + STRMOVE(t + 1, t + 2); } term_strings[p->bt_entry] = s; set_term_option_alloced(&term_strings[p->bt_entry]); diff --git a/src/version.c b/src/version.c index 58751e3215..982d111878 100644 --- a/src/version.c +++ b/src/version.c @@ -789,6 +789,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 176, /**/ 175, /**/ From 93343725b5fa1cf580a24302455980faacae8ee2 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 10 Jul 2018 19:39:18 +0200 Subject: [PATCH 4/5] patch 8.1.0177: defining function in sandbox is inconsistent Problem: Defining function in sandbox is inconsistent, cannot use :function but can define a lambda. Solution: Allow defining a function in the sandbox, but also use the sandbox when executing it. (closes #3182) --- src/ex_cmds.h | 2 +- src/userfunc.c | 29 ++++++++++++++++++++++------- src/version.c | 2 ++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/ex_cmds.h b/src/ex_cmds.h index 48b0253157..045bfcb203 100644 --- a/src/ex_cmds.h +++ b/src/ex_cmds.h @@ -584,7 +584,7 @@ EX(CMD_for, "for", ex_while, EXTRA|NOTRLCOM|SBOXOK|CMDWIN, ADDR_LINES), EX(CMD_function, "function", ex_function, - EXTRA|BANG|CMDWIN, + EXTRA|BANG|SBOXOK|CMDWIN, ADDR_LINES), EX(CMD_global, "global", ex_global, RANGE|WHOLEFOLD|BANG|EXTRA|DFLALL|SBOXOK|CMDWIN, diff --git a/src/userfunc.c b/src/userfunc.c index 71acaecc3a..80a603b16e 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -14,13 +14,14 @@ #include "vim.h" #if defined(FEAT_EVAL) || defined(PROTO) -/* function flags */ -#define FC_ABORT 0x01 /* abort function on error */ -#define FC_RANGE 0x02 /* function accepts range */ -#define FC_DICT 0x04 /* Dict function, uses "self" */ -#define FC_CLOSURE 0x08 /* closure, uses outer scope variables */ -#define FC_DELETED 0x10 /* :delfunction used while uf_refcount > 0 */ -#define FC_REMOVED 0x20 /* function redefined while uf_refcount > 0 */ +// flags used in uf_flags +#define FC_ABORT 0x01 // abort function on error +#define FC_RANGE 0x02 // function accepts range +#define FC_DICT 0x04 // Dict function, uses "self" +#define FC_CLOSURE 0x08 // closure, uses outer scope variables +#define FC_DELETED 0x10 // :delfunction used while uf_refcount > 0 +#define FC_REMOVED 0x20 // function redefined while uf_refcount > 0 +#define FC_SANDBOX 0x40 // function defined in the sandbox /* From user function to hashitem and back. */ #define UF2HIKEY(fp) ((fp)->uf_name) @@ -296,6 +297,8 @@ get_lambda_tv(char_u **arg, typval_T *rettv, int evaluate) if (prof_def_func()) func_do_profile(fp); #endif + if (sandbox) + flags |= FC_SANDBOX; fp->uf_varargs = TRUE; fp->uf_flags = flags; fp->uf_calls = 0; @@ -688,6 +691,7 @@ call_user_func( char_u *save_sourcing_name; linenr_T save_sourcing_lnum; scid_T save_current_SID; + int using_sandbox = FALSE; funccall_T *fc; int save_did_emsg; static int depth = 0; @@ -854,6 +858,13 @@ call_user_func( save_sourcing_name = sourcing_name; save_sourcing_lnum = sourcing_lnum; sourcing_lnum = 1; + + if (fp->uf_flags & FC_SANDBOX) + { + using_sandbox = TRUE; + ++sandbox; + } + /* need space for function name + ("function " + 3) or "[number]" */ len = (save_sourcing_name == NULL ? 0 : STRLEN(save_sourcing_name)) + STRLEN(fp->uf_name) + 20; @@ -1020,6 +1031,8 @@ call_user_func( if (do_profiling == PROF_YES) script_prof_restore(&wait_start); #endif + if (using_sandbox) + --sandbox; if (p_verbose >= 12 && sourcing_name != NULL) { @@ -2429,6 +2442,8 @@ ex_function(exarg_T *eap) func_do_profile(fp); #endif fp->uf_varargs = varargs; + if (sandbox) + flags |= FC_SANDBOX; fp->uf_flags = flags; fp->uf_calls = 0; fp->uf_script_ID = current_SID; diff --git a/src/version.c b/src/version.c index 982d111878..88d3b7e8b2 100644 --- a/src/version.c +++ b/src/version.c @@ -789,6 +789,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 177, /**/ 176, /**/ From e76c4b237d41d0e62ca5d4fc76d1dd163fe222c0 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 11 Jul 2018 22:57:54 +0200 Subject: [PATCH 5/5] patch 8.1.0178: warning for passing pointer to non-pointer argument Problem: Warning for passing pointer to non-pointer argument. Solution: Use zero instead of NULL. --- src/if_ole.cpp | 2 +- src/version.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/if_ole.cpp b/src/if_ole.cpp index aaa3868ef6..0888883630 100644 --- a/src/if_ole.cpp +++ b/src/if_ole.cpp @@ -759,7 +759,7 @@ extern "C" void InitOLE(int *pbDoRestart) hr = RegisterActiveObject( app, MYCLSID, - NULL, + 0, &app_id); if (FAILED(hr)) diff --git a/src/version.c b/src/version.c index 88d3b7e8b2..1f94b015f3 100644 --- a/src/version.c +++ b/src/version.c @@ -789,6 +789,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 178, /**/ 177, /**/