Problem: One character cmdline abbreviation not triggered after '<,'>.
Solution: Skip over the special range. (Christian Brabandt, closes #2320)
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 (VIM_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);
}
#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
delfunc Eatchar
bw!
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
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1837,
/**/
1836,
/**/