# HG changeset patch # User Christian Brabandt # Date 1478379604 -3600 # Node ID ae0faad76f9a234b83774f14f6373547c441c89a # Parent baa541894b8385cf826b498487be1a42f0d75b8e commit https://github.com/vim/vim/commit/4a08b0dc4dd70334056fc1bf069b5e938f2ed7d5 Author: Bram Moolenaar Date: Sat Nov 5 21:55:13 2016 +0100 patch 8.0.0066 Problem: when calling an operator function when 'linebreak' is set, it is internally reset before calling the operator function. Solution: Restore 'linebreak' before calling op_function(). (Christian Brabandt) diff --git a/src/normal.c b/src/normal.c --- a/src/normal.c +++ b/src/normal.c @@ -1995,6 +1995,11 @@ do_pending_operator(cmdarg_T *cap, int o break; case OP_FUNCTION: +#ifdef FEAT_LINEBREAK + /* Restore linebreak, so that when the user edits it looks as + * before. */ + curwin->w_p_lbr = lbr_saved; +#endif op_function(oap); /* call 'operatorfunc' */ break; diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim --- a/src/testdir/test_normal.vim +++ b/src/testdir/test_normal.vim @@ -35,8 +35,20 @@ func! CountSpaces(type, ...) let @@ = reg_save endfunc -func! IsWindows() - return has("win32") || has("win64") || has("win95") +func! OpfuncDummy(type, ...) + " for testing operatorfunc + let g:opt=&linebreak + + if a:0 " Invoked from Visual mode, use gv command. + silent exe "normal! gvy" + elseif a:type == 'line' + silent exe "normal! '[V']y" + else + silent exe "normal! `[v`]y" + endif + " Create a new dummy window + new + let g:bufnr=bufnr('%') endfunc fun! Test_normal00_optrans() @@ -147,7 +159,7 @@ endfunc func! Test_normal04_filter() " basic filter test " only test on non windows platform - if IsWindows() + if has('win32') return endif call Setup_NewWindow() @@ -210,7 +222,7 @@ endfunc func! Test_normal06_formatprg() " basic test for formatprg " only test on non windows platform - if IsWindows() + if has('win32') return else " uses sed to number non-empty lines @@ -328,9 +340,36 @@ func! Test_normal09_operatorfunc() " clean up unmap ,, set opfunc= + unlet! g:a bw! endfunc +func! Test_normal09a_operatorfunc() + " Test operatorfunc + call Setup_NewWindow() + " Add some spaces for counting + 50,60s/$/ / + unlet! g:opt + set linebreak + nmap ,, :set opfunc=OpfuncDummyg@ + 50 + norm ,,j + exe "bd!" g:bufnr + call assert_true(&linebreak) + call assert_equal(g:opt, &linebreak) + set nolinebreak + norm ,,j + exe "bd!" g:bufnr + call assert_false(&linebreak) + call assert_equal(g:opt, &linebreak) + + " clean up + unmap ,, + set opfunc= + bw! + unlet! g:opt +endfunc + func! Test_normal10_expand() " Test for expand() 10new diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -765,6 +765,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 66, +/**/ 65, /**/ 64,