Skip to content

Commit 5e3423d

Browse files
committed
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 #2320)
1 parent 25782a7 commit 5e3423d

3 files changed

Lines changed: 34 additions & 1 deletion

File tree

src/ex_getln.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3572,10 +3572,25 @@ gotocmdline(int clr)
35723572
static int
35733573
ccheck_abbr(int c)
35743574
{
3575+
int spos = 0;
3576+
35753577
if (p_paste || no_abbr) /* no abbreviations or in paste mode */
35763578
return FALSE;
35773579

3578-
return check_abbr(c, ccline.cmdbuff, ccline.cmdpos, 0);
3580+
/* Do not consider '<,'> be part of the mapping, skip leading whitespace.
3581+
* Actually accepts any mark. */
3582+
while (VIM_ISWHITE(ccline.cmdbuff[spos]) && spos < ccline.cmdlen)
3583+
spos++;
3584+
if (ccline.cmdlen - spos > 5
3585+
&& ccline.cmdbuff[spos] == '\''
3586+
&& ccline.cmdbuff[spos + 2] == ','
3587+
&& ccline.cmdbuff[spos + 3] == '\'')
3588+
spos += 5;
3589+
else
3590+
/* check abbreviation from the beginning of the commandline */
3591+
spos = 0;
3592+
3593+
return check_abbr(c, ccline.cmdbuff, ccline.cmdpos, spos);
35793594
}
35803595

35813596
#if defined(FEAT_CMDL_COMPL) || defined(PROTO)

src/testdir/test_mapping.vim

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,19 @@ func Test_abbreviation_CR()
214214
delfunc Eatchar
215215
bw!
216216
endfunc
217+
218+
func Test_cabbr_visual_mode()
219+
cabbr s su
220+
call feedkeys(":s \<c-B>\"\<CR>", 'itx')
221+
call assert_equal('"su ', getreg(':'))
222+
call feedkeys(":'<,'>s \<c-B>\"\<CR>", 'itx')
223+
let expected = '"'. "'<,'>su "
224+
call assert_equal(expected, getreg(':'))
225+
call feedkeys(": '<,'>s \<c-B>\"\<CR>", 'itx')
226+
let expected = '" '. "'<,'>su "
227+
call assert_equal(expected, getreg(':'))
228+
call feedkeys(":'a,'bs \<c-B>\"\<CR>", 'itx')
229+
let expected = '"'. "'a,'bsu "
230+
call assert_equal(expected, getreg(':'))
231+
cunabbr s
232+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1837,
764766
/**/
765767
1836,
766768
/**/

0 commit comments

Comments
 (0)