Mercurial > vim
comparison src/testdir/test_normal.vim @ 26903:5aa9e8db975c v8.2.3980
patch 8.2.3980: if 'operatorfunc' invokes an operator Visual mode is changed
Commit: https://github.com/vim/vim/commit/b3bd1d39e68e2d697c014b9f85482c2c12a3f909
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 2 13:05:45 2022 +0000
patch 8.2.3980: if 'operatorfunc' invokes an operator Visual mode is changed
Problem: If 'operatorfunc' invokes an operator the remembered Visual mode
may be changed. (Naohiro Ono)
Solution: Save and restore the information for redoing the Visual area.
(closes #9455)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 02 Jan 2022 14:15:03 +0100 |
parents | fb67cd7d30a7 |
children | 85b4bd8f8e5d |
comparison
equal
deleted
inserted
replaced
26902:3c0792bb8be6 | 26903:5aa9e8db975c |
---|---|
462 | 462 |
463 func OperatorfuncRedo(_) | 463 func OperatorfuncRedo(_) |
464 let g:opfunc_count = v:count | 464 let g:opfunc_count = v:count |
465 endfunc | 465 endfunc |
466 | 466 |
467 func Underscorize(_) | |
468 normal! '[V']r_ | |
469 endfunc | |
470 | |
467 func Test_normal09c_operatorfunc() | 471 func Test_normal09c_operatorfunc() |
468 " Test redoing operatorfunc | 472 " Test redoing operatorfunc |
469 new | 473 new |
470 call setline(1, 'some text') | 474 call setline(1, 'some text') |
471 set operatorfunc=OperatorfuncRedo | 475 set operatorfunc=OperatorfuncRedo |
475 normal . | 479 normal . |
476 call assert_equal(3, g:opfunc_count) | 480 call assert_equal(3, g:opfunc_count) |
477 | 481 |
478 bw! | 482 bw! |
479 unlet g:opfunc_count | 483 unlet g:opfunc_count |
484 | |
485 " Test redoing Visual mode | |
486 set operatorfunc=Underscorize | |
487 new | |
488 call setline(1, ['first', 'first', 'third', 'third', 'second']) | |
489 normal! 1GVjr_ | |
490 normal! 5G. | |
491 normal! 3G. | |
492 call assert_equal(['_____', '_____', '_____', '_____', '______'], getline(1, '$')) | |
493 bwipe! | |
480 set operatorfunc= | 494 set operatorfunc= |
481 endfunc | 495 endfunc |
482 | 496 |
483 " Test for different ways of setting the 'operatorfunc' option | 497 " Test for different ways of setting the 'operatorfunc' option |
484 func Test_opfunc_callback() | 498 func Test_opfunc_callback() |