diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-10-10 23:19:52 -0400 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-10-10 23:24:38 -0400 |
commit | 25baeb39e3e93325bdbacbb96fd4f6d1dc1a3250 (patch) | |
tree | 8e11619bb68ddd23fa67d1960b9996e73a555f3b /src | |
parent | e17e21e4cfb4c9c402b26e49f36af6c2ca6239ec (diff) | |
download | rneovim-25baeb39e3e93325bdbacbb96fd4f6d1dc1a3250.tar.gz rneovim-25baeb39e3e93325bdbacbb96fd4f6d1dc1a3250.tar.bz2 rneovim-25baeb39e3e93325bdbacbb96fd4f6d1dc1a3250.zip |
vim-patch:8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Problem: One character cmdline abbreviation not triggered after '<,'>.
Solution: Skip over the special range. (Christian Brabandt, closes vim/vim#2320)
https://github.com/vim/vim/commit/5e3423d192bfa502c6704f731fa2ec6821f9a2f0
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ex_getln.c | 19 | ||||
-rw-r--r-- | src/nvim/testdir/test_mapping.vim | 16 |
2 files changed, 34 insertions, 1 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 1ec00b1e25..ac71e2df7e 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -3522,10 +3522,27 @@ void gotocmdline(int clr) */ static int ccheck_abbr(int c) { + int spos = 0; + if (p_paste || no_abbr) /* no abbreviations or in paste mode */ return FALSE; - return check_abbr(c, ccline.cmdbuff, ccline.cmdpos, 0); + // Do not consider '<,'> be part of the mapping, skip leading whitespace. + // Actually accepts any mark. + while (ascii_iswhite(ccline.cmdbuff[spos]) && spos < ccline.cmdlen) { + spos++; + } + if (ccline.cmdlen - spos > 5 + && ccline.cmdbuff[spos] == '\'' + && ccline.cmdbuff[spos + 2] == ',' + && ccline.cmdbuff[spos + 3] == '\'') { + spos += 5; + } else { + // check abbreviation from the beginning of the commandline + spos = 0; + } + + return check_abbr(c, ccline.cmdbuff, ccline.cmdpos, spos); } static int sort_func_compare(const void *s1, const void *s2) diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim index f4fe1c2705..071b8b369b 100644 --- a/src/nvim/testdir/test_mapping.vim +++ b/src/nvim/testdir/test_mapping.vim @@ -198,3 +198,19 @@ func Test_map_timeout() set timeoutlen& delfunc ExitInsert endfunc + +func Test_cabbr_visual_mode() + cabbr s su + call feedkeys(":s \<c-B>\"\<CR>", 'itx') + call assert_equal('"su ', getreg(':')) + call feedkeys(":'<,'>s \<c-B>\"\<CR>", 'itx') + let expected = '"'. "'<,'>su " + call assert_equal(expected, getreg(':')) + call feedkeys(": '<,'>s \<c-B>\"\<CR>", 'itx') + let expected = '" '. "'<,'>su " + call assert_equal(expected, getreg(':')) + call feedkeys(":'a,'bs \<c-B>\"\<CR>", 'itx') + let expected = '"'. "'a,'bsu " + call assert_equal(expected, getreg(':')) + cunabbr s +endfunc |