Skip to content

Commit 4a08b0d

Browse files
committed
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)
1 parent 40d3f13 commit 4a08b0d

3 files changed

Lines changed: 50 additions & 4 deletions

File tree

src/normal.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,6 +1995,11 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
19951995
break;
19961996

19971997
case OP_FUNCTION:
1998+
#ifdef FEAT_LINEBREAK
1999+
/* Restore linebreak, so that when the user edits it looks as
2000+
* before. */
2001+
curwin->w_p_lbr = lbr_saved;
2002+
#endif
19982003
op_function(oap); /* call 'operatorfunc' */
19992004
break;
20002005

src/testdir/test_normal.vim

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,20 @@ func! CountSpaces(type, ...)
3535
let @@ = reg_save
3636
endfunc
3737

38-
func! IsWindows()
39-
return has("win32") || has("win64") || has("win95")
38+
func! OpfuncDummy(type, ...)
39+
" for testing operatorfunc
40+
let g:opt=&linebreak
41+
42+
if a:0 " Invoked from Visual mode, use gv command.
43+
silent exe "normal! gvy"
44+
elseif a:type == 'line'
45+
silent exe "normal! '[V']y"
46+
else
47+
silent exe "normal! `[v`]y"
48+
endif
49+
" Create a new dummy window
50+
new
51+
let g:bufnr=bufnr('%')
4052
endfunc
4153

4254
fun! Test_normal00_optrans()
@@ -147,7 +159,7 @@ endfunc
147159
func! Test_normal04_filter()
148160
" basic filter test
149161
" only test on non windows platform
150-
if IsWindows()
162+
if has('win32')
151163
return
152164
endif
153165
call Setup_NewWindow()
@@ -210,7 +222,7 @@ endfunc
210222
func! Test_normal06_formatprg()
211223
" basic test for formatprg
212224
" only test on non windows platform
213-
if IsWindows()
225+
if has('win32')
214226
return
215227
else
216228
" uses sed to number non-empty lines
@@ -325,10 +337,37 @@ func! Test_normal09_operatorfunc()
325337
norm V10j,,
326338
call assert_equal(22, g:a)
327339

340+
" clean up
341+
unmap <buffer> ,,
342+
set opfunc=
343+
unlet! g:a
344+
bw!
345+
endfunc
346+
347+
func! Test_normal09a_operatorfunc()
348+
" Test operatorfunc
349+
call Setup_NewWindow()
350+
" Add some spaces for counting
351+
50,60s/$/ /
352+
unlet! g:opt
353+
set linebreak
354+
nmap <buffer><silent> ,, :set opfunc=OpfuncDummy<CR>g@
355+
50
356+
norm ,,j
357+
exe "bd!" g:bufnr
358+
call assert_true(&linebreak)
359+
call assert_equal(g:opt, &linebreak)
360+
set nolinebreak
361+
norm ,,j
362+
exe "bd!" g:bufnr
363+
call assert_false(&linebreak)
364+
call assert_equal(g:opt, &linebreak)
365+
328366
" clean up
329367
unmap <buffer> ,,
330368
set opfunc=
331369
bw!
370+
unlet! g:opt
332371
endfunc
333372

334373
func! Test_normal10_expand()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
66,
767769
/**/
768770
65,
769771
/**/

0 commit comments

Comments
 (0)