Mercurial > vim
comparison src/testdir/test_mapping.vim @ 18689:8cc12c8d7842 v8.1.2336
patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Commit: https://github.com/vim/vim/commit/4ebe0e62d097d68c5312f9c32714fb41a4c947a3
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Nov 22 20:55:40 2019 +0100
patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Problem: When an expr mapping moves the cursor it is not restored.
Solution: Position the cursor after an expr mapping. (closes https://github.com/vim/vim/issues/5256)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 22 Nov 2019 21:00:04 +0100 |
parents | 5b12fd0c39c3 |
children | 643c6c3c0da4 |
comparison
equal
deleted
inserted
replaced
18688:b291f5642a2c | 18689:8cc12c8d7842 |
---|---|
1 " Tests for mappings and abbreviations | 1 " Tests for mappings and abbreviations |
2 | 2 |
3 source shared.vim | 3 source shared.vim |
4 source check.vim | 4 source check.vim |
5 source screendump.vim | |
5 | 6 |
6 func Test_abbreviation() | 7 func Test_abbreviation() |
7 " abbreviation with 0x80 should work | 8 " abbreviation with 0x80 should work |
8 inoreab чкпр vim | 9 inoreab чкпр vim |
9 call feedkeys("Goчкпр \<Esc>", "xt") | 10 call feedkeys("Goчкпр \<Esc>", "xt") |
459 iunmap <A-S> | 460 iunmap <A-S> |
460 call assert_equal(['i <S-/> * ShiftSlash'], execute('imap')->trim()->split("\n")) | 461 call assert_equal(['i <S-/> * ShiftSlash'], execute('imap')->trim()->split("\n")) |
461 iunmap <S-/> | 462 iunmap <S-/> |
462 call assert_equal(['No mapping found'], execute('imap')->trim()->split("\n")) | 463 call assert_equal(['No mapping found'], execute('imap')->trim()->split("\n")) |
463 endfunc | 464 endfunc |
465 | |
466 func Test_expr_map_restore_cursor() | |
467 CheckScreendump | |
468 | |
469 let lines =<< trim END | |
470 call setline(1, ['one', 'two', 'three']) | |
471 2 | |
472 set ls=2 | |
473 hi! link StatusLine ErrorMsg | |
474 noremap <expr> <C-B> Func() | |
475 func Func() | |
476 let g:on = !get(g:, 'on', 0) | |
477 redraws | |
478 return '' | |
479 endfunc | |
480 func Status() | |
481 return get(g:, 'on', 0) ? '[on]' : '' | |
482 endfunc | |
483 set stl=%{Status()} | |
484 END | |
485 call writefile(lines, 'XtestExprMap') | |
486 let buf = RunVimInTerminal('-S XtestExprMap', #{rows: 10}) | |
487 call term_wait(buf) | |
488 call term_sendkeys(buf, "\<C-B>") | |
489 call VerifyScreenDump(buf, 'Test_map_expr_1', {}) | |
490 | |
491 " clean up | |
492 call StopVimInTerminal(buf) | |
493 call delete('XtestExprMap') | |
494 endfunc |