Bram,
I just recently got a bug report for my NarrowRegion plugin 
(https://github.com/chrisbra/NrrwRgn/issues/54)

It turns out, that when calling an operator function when 'linebreak' is 
set, it is internally reset before calling the operator function and 
since my plugin creates a new window, it will be set back in the wrong 
window.

Attached is a patch that fixes it and a test.

Best,
Christian
-- 
Loch in Erde,
Bronze rin.
Glocke fertig,
Bim bim bimm.
                -- Frei nach Friedrich Schiller

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
From 020772a71285d750a62df7ca1b353eb5d88ef9b9 Mon Sep 17 00:00:00 2001
From: Christian Brabandt <c...@256bit.org>
Date: Sat, 5 Nov 2016 17:23:19 +0100
Subject: [PATCH] Reset linebreak before calling operatorfunc

---
 src/normal.c                |  6 ++++++
 src/testdir/test_normal.vim | 43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)

diff --git a/src/normal.c b/src/normal.c
index 99ced41..17f58a6 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -1995,6 +1995,12 @@ 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. */
+	    if (curwin->w_p_lbr != lbr_saved)
+		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
index f896046..da43bed 100644
--- a/src/testdir/test_normal.vim
+++ b/src/testdir/test_normal.vim
@@ -35,6 +35,22 @@ func! CountSpaces(type, ...)
   let @@ = reg_save
 endfunc
 
+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
+
 func! IsWindows()
   return has("win32") || has("win64") || has("win95")
 endfunc
@@ -328,7 +344,34 @@ func! Test_normal09_operatorfunc()
   " 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()
-- 
2.9.3

Raspunde prin e-mail lui