aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorraichoo <raichoo@googlemail.com>2017-03-11 12:00:36 +0100
committerraichoo <raichoo@googlemail.com>2017-03-19 21:14:11 +0100
commita4f20db08ce2824d3a63b5ae50aabbea14830ac2 (patch)
treec11c77c3c37a9e4728d06305c90ec1772daffb9d
parent88dd2e8a085f88bb8b3c7ded86d5d0ac1ebaf58b (diff)
downloadrneovim-a4f20db08ce2824d3a63b5ae50aabbea14830ac2.tar.gz
rneovim-a4f20db08ce2824d3a63b5ae50aabbea14830ac2.tar.bz2
rneovim-a4f20db08ce2824d3a63b5ae50aabbea14830ac2.zip
vim-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) https://github.com/vim/vim/commit/4a08b0dc4dd70334056fc1bf069b5e938f2ed7d5
-rw-r--r--src/nvim/normal.c3
-rw-r--r--src/nvim/testdir/test_normal.vim47
2 files changed, 46 insertions, 4 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 49085a27a0..489eec8474 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -1914,6 +1914,9 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
break;
case OP_FUNCTION:
+ // Restore linebreak, so that when the user edits it looks as
+ // before.
+ curwin->w_p_lbr = lbr_saved;
op_function(oap); /* call 'operatorfunc' */
break;
diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim
index 4dafe3c105..29bd783ebc 100644
--- a/src/nvim/testdir/test_normal.vim
+++ b/src/nvim/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,7 +340,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()