]> granicus.if.org Git - vim/commitdiff
patch 8.0.0066 v8.0.0066
authorBram Moolenaar <Bram@vim.org>
Sat, 5 Nov 2016 20:55:13 +0000 (21:55 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 5 Nov 2016 20:55:13 +0000 (21:55 +0100)
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)

src/normal.c
src/testdir/test_normal.vim
src/version.c

index f5e5475f335a4eb3d218280beb4dd13c840a2fd5..5d0796f4744c1dace549d163e8cb60a033672d1a 100644 (file)
@@ -1995,6 +1995,11 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
            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;
 
index 4dafe3c105fc874b2627603221c7098fc0a4d9fe..29bd783ebc5c6b5c1d582d99404811baaee699de 100644 (file)
@@ -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
@@ -325,10 +337,37 @@ func! Test_normal09_operatorfunc()
   norm V10j,,
   call assert_equal(22, g:a)
 
+  " clean up
+  unmap <buffer> ,,
+  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 <buffer><silent> ,, :set opfunc=OpfuncDummy<CR>g@
+  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 <buffer> ,,
   set opfunc=
   bw!
+  unlet! g:opt
 endfunc
 
 func! Test_normal10_expand()
index 2b5d656ae7a71d4d01dce35372345f128551b27f..a19ef5b506ab70bb34373fff31c5f823096509b2 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    66,
 /**/
     65,
 /**/