Patch 8.1.2336

7 views
Skip to first unread message

Bram Moolenaar

unread,
Nov 22, 2019, 2:57:11 PM11/22/19
to vim...@googlegroups.com

Patch 8.1.2336
Problem: When an expr mapping moves the cursor it is not restored.
Solution: Position the cursor after an expr mapping. (closes #5256)
Files: src/getchar.c, src/testdir/test_mapping.vim,
src/testdir/dumps/Test_map_expr_1.dump


*** ../vim-8.1.2335/src/getchar.c 2019-11-21 23:23:56.671658025 +0100
--- src/getchar.c 2019-11-22 20:54:33.759811542 +0100
***************
*** 2594,2599 ****
--- 2594,2601 ----
{
int save_vgetc_busy = vgetc_busy;
int save_may_garbage_collect = may_garbage_collect;
+ int was_screen_col = screen_cur_col;
+ int was_screen_row = screen_cur_row;

vgetc_busy = 0;
may_garbage_collect = FALSE;
***************
*** 2602,2607 ****
--- 2604,2614 ----
save_m_str = vim_strsave(mp->m_str);
map_str = eval_map_expr(save_m_str, NUL);

+ // The mapping may do anything, but we expect it to take care of
+ // redrawing. Do put the cursor back where it was.
+ windgoto(was_screen_row, was_screen_col);
+ out_flush();
+
vgetc_busy = save_vgetc_busy;
may_garbage_collect = save_may_garbage_collect;
}
*** ../vim-8.1.2335/src/testdir/test_mapping.vim 2019-10-16 23:33:09.214421043 +0200
--- src/testdir/test_mapping.vim 2019-11-22 20:50:37.164728436 +0100
***************
*** 2,7 ****
--- 2,8 ----

source shared.vim
source check.vim
+ source screendump.vim

func Test_abbreviation()
" abbreviation with 0x80 should work
***************
*** 461,463 ****
--- 462,494 ----
iunmap <S-/>
call assert_equal(['No mapping found'], execute('imap')->trim()->split("\n"))
endfunc
+
+ func Test_expr_map_restore_cursor()
+ CheckScreendump
+
+ let lines =<< trim END
+ call setline(1, ['one', 'two', 'three'])
+ 2
+ set ls=2
+ hi! link StatusLine ErrorMsg
+ noremap <expr> <C-B> Func()
+ func Func()
+ let g:on = !get(g:, 'on', 0)
+ redraws
+ return ''
+ endfunc
+ func Status()
+ return get(g:, 'on', 0) ? '[on]' : ''
+ endfunc
+ set stl=%{Status()}
+ END
+ call writefile(lines, 'XtestExprMap')
+ let buf = RunVimInTerminal('-S XtestExprMap', #{rows: 10})
+ call term_wait(buf)
+ call term_sendkeys(buf, "\<C-B>")
+ call VerifyScreenDump(buf, 'Test_map_expr_1', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
+ call delete('XtestExprMap')
+ endfunc
*** ../vim-8.1.2335/src/testdir/dumps/Test_map_expr_1.dump 2019-11-22 20:55:04.663691078 +0100
--- src/testdir/dumps/Test_map_expr_1.dump 2019-11-22 20:51:14.724583582 +0100
***************
*** 0 ****
--- 1,10 ----
+ |o+0&#ffffff0|n|e| @71
+ >t|w|o| @71
+ |t|h|r|e@1| @69
+ |~+0#4040ff13&| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |[+0#ffffff16#e000002|o|n|]| @70
+ | +0#0000000#ffffff0@74
*** ../vim-8.1.2335/src/version.c 2019-11-22 19:29:42.521805447 +0100
--- src/version.c 2019-11-22 20:45:59.065807045 +0100
***************
*** 739,740 ****
--- 739,742 ----
{ /* Add new patch number below this line */
+ /**/
+ 2336,
/**/

--
hundred-and-one symptoms of being an internet addict:
107. When using your phone you forget that you don't have to use your
keyboard.

/// 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 ///
Reply all
Reply to author
Forward
0 new messages