Skip to content

Commit

Permalink
patch 8.0.1837: one character cmdline abbreviation not triggered afte…
Browse files Browse the repository at this point in the history
…r '<,'>

Problem:    One character cmdline abbreviation not triggered after '<,'>.
Solution:   Skip over the special range. (Christian Brabandt, closes #2320)
  • Loading branch information
brammool committed May 13, 2018
1 parent 25782a7 commit 5e3423d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/ex_getln.c
Original file line number Diff line number Diff line change
Expand Up @@ -3572,10 +3572,25 @@ 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 (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] == '\'')

This comment has been minimized.

Copy link
@Konfekt

Konfekt May 14, 2018

Contributor

@chrisbra

Does this check not lead to inconsistencies, for example, with iabb b B and iabb bb BB, then 'a,'bb would expand to 'a,'bB instead of 'a,'BB?

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)
Expand Down
16 changes: 16 additions & 0 deletions src/testdir/test_mapping.vim
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,19 @@ func Test_abbreviation_CR()
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
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1837,
/**/
1836,
/**/
Expand Down

0 comments on commit 5e3423d

Please sign in to comment.