Patch 8.2.2005

16 views
Skip to first unread message

Bram Moolenaar

unread,
Nov 18, 2020, 5:35:12 AM11/18/20
to vim...@googlegroups.com

Patch 8.2.2005
Problem: Redoing a mapping with <Cmd> doesn't work properly.
Solution: Fill the redo buffer. Use "<SNR>" instead of a key code.
(closes #7282)
Files: src/ops.c, src/getchar.c, src/testdir/test_mapping.vim


*** ../vim-8.2.2004/src/ops.c 2020-11-12 14:20:32.025927280 +0100
--- src/ops.c 2020-11-17 21:56:25.617238501 +0100
***************
*** 3465,3472 ****
if ((redo_yank || oap->op_type != OP_YANK)
&& ((!VIsual_active || oap->motion_force)
// Also redo Operator-pending Visual mode mappings
! || (VIsual_active && cap->cmdchar == ':'
! && oap->op_type != OP_COLON))
&& cap->cmdchar != 'D'
#ifdef FEAT_FOLDING
&& oap->op_type != OP_FOLD
--- 3465,3473 ----
if ((redo_yank || oap->op_type != OP_YANK)
&& ((!VIsual_active || oap->motion_force)
// Also redo Operator-pending Visual mode mappings
! || (VIsual_active
! && (cap->cmdchar == ':' || cap->cmdchar == K_COMMAND)
! && oap->op_type != OP_COLON))
&& cap->cmdchar != 'D'
#ifdef FEAT_FOLDING
&& oap->op_type != OP_FOLD
***************
*** 3688,3694 ****
get_op_char(oap->op_type),
get_extra_op_char(oap->op_type),
oap->motion_force, cap->cmdchar, cap->nchar);
! else if (cap->cmdchar != ':')
{
int nchar = oap->op_type == OP_REPLACE ? cap->nchar : NUL;

--- 3689,3695 ----
get_op_char(oap->op_type),
get_extra_op_char(oap->op_type),
oap->motion_force, cap->cmdchar, cap->nchar);
! else if (cap->cmdchar != ':' && cap->cmdchar != K_COMMAND)
{
int nchar = oap->op_type == OP_REPLACE ? cap->nchar : NUL;

*** ../vim-8.2.2004/src/getchar.c 2020-11-15 20:49:36.979163804 +0100
--- src/getchar.c 2020-11-17 22:18:15.222053492 +0100
***************
*** 3691,3701 ****
else if (IS_SPECIAL(c1))
{
if (c1 == K_SNR)
! {
! ga_append(&line_ga, (char)K_SPECIAL);
! ga_append(&line_ga, (char)KS_EXTRA);
! ga_append(&line_ga, (char)KE_SNR);
! }
else
{
semsg(e_cmd_maping_must_not_include_str_key,
--- 3691,3697 ----
else if (IS_SPECIAL(c1))
{
if (c1 == K_SNR)
! ga_concat(&line_ga, (char_u *)"<SNR>");
else
{
semsg(e_cmd_maping_must_not_include_str_key,
*** ../vim-8.2.2004/src/testdir/test_mapping.vim 2020-11-12 14:20:32.025927280 +0100
--- src/testdir/test_mapping.vim 2020-11-18 11:33:42.554346535 +0100
***************
*** 1324,1327 ****
--- 1324,1363 ----
%bw!
endfunc

+ func Test_map_cmdkey_redo()
+ func SelectDash()
+ call search('^---\n\zs', 'bcW')
+ norm! V
+ call search('\n\ze---$', 'W')
+ endfunc
+
+ let text =<< trim END
+ ---
+ aaa
+ ---
+ bbb
+ bbb
+ ---
+ ccc
+ ccc
+ ccc
+ ---
+ END
+ new Xcmdtext
+ call setline(1, text)
+
+ onoremap <silent> i- <Cmd>call SelectDash()<CR>
+ call feedkeys('2Gdi-', 'xt')
+ call assert_equal(['---', '---'], getline(1, 2))
+ call feedkeys('j.', 'xt')
+ call assert_equal(['---', '---', '---'], getline(1, 3))
+ call feedkeys('j.', 'xt')
+ call assert_equal(['---', '---', '---', '---'], getline(1, 4))
+
+ bwipe!
+ call delete('Xcmdtext')
+ delfunc SelectDash
+ ounmap i-
+ endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.2004/src/version.c 2020-11-17 19:56:05.534193964 +0100
--- src/version.c 2020-11-18 11:34:04.454275176 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2005,
/**/

--
hundred-and-one symptoms of being an internet addict:
269. You receive an e-mail from the wife of a deceased president, offering
to send you twenty million dollar, and you are not even surprised.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Yegappan Lakshmanan

unread,
Nov 18, 2020, 6:53:03 AM11/18/20
to vim_dev
Hi Bram,

On Wed, Nov 18, 2020 at 2:35 AM Bram Moolenaar <Br...@moolenaar.net> wrote:

Patch 8.2.2005
Problem:    Redoing a mapping with <Cmd> doesn't work properly.
Solution:   Fill the redo buffer.  Use "<SNR>" instead of a key code.
            (closes #7282)
Files:      src/ops.c, src/getchar.c, src/testdir/test_mapping.vim


Thanks for addressing this. I have been looking into this. As I haven't worked
with the redo logic before, I couldn't make much progress.

Regards,
Yegappan

Bram Moolenaar

unread,
Nov 18, 2020, 7:39:27 AM11/18/20
to vim...@googlegroups.com, Yegappan Lakshmanan
Yeah, this is some special trick to make redo work with an Ex command.
Now we need to do this both for ":" and <Cmd>.
I suppose Neovim has the same problem?

--
God made the integers; all else is the work of Man.
-- Kronecker

Yegappan Lakshmanan

unread,
Nov 18, 2020, 7:42:32 AM11/18/20
to Bram Moolenaar, vim_dev
On Wed, Nov 18, 2020 at 4:39 AM Bram Moolenaar <Br...@moolenaar.net> wrote:

Yegappan wrote:

> On Wed, Nov 18, 2020 at 2:35 AM Bram Moolenaar <Br...@moolenaar.net> wrote:
>
> >
> > Patch 8.2.2005
> > Problem:    Redoing a mapping with <Cmd> doesn't work properly.
> > Solution:   Fill the redo buffer.  Use "<SNR>" instead of a key code.
> >             (closes #7282)
> > Files:      src/ops.c, src/getchar.c, src/testdir/test_mapping.vim
> >
> >
> Thanks for addressing this. I have been looking into this. As I haven't
> worked with the redo logic before, I couldn't make much progress.

Yeah, this is some special trick to make redo work with an Ex command.
Now we need to do this both for ":" and <Cmd>.
I suppose Neovim has the same problem?
 

Yes. Neovim also has the same problem with redoing the <Cmd> command
in operator pending mode.

- Yegappan
 
Reply all
Reply to author
Forward
0 new messages